This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients serhiy.storchaka, vstinner
Date 2016-03-25.18:20:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1458930024.17.0.00462396415924.issue26643@psf.upfronthosting.co.za>
In-reply-to
Content
(I pushed the change 245a16f33c4b, but Serhiy asked me to review it and discuss it. So I reverted my change and created this issue.)

I noticed many times that buildbots log "test xxx changed yyy" but this line is not enough to debug the issue. I propose to always display the old and new value to easy debugging these issues.

Sometimes, I try to reproduce the issue, but I fail to reproduce it locally. I may depend on the test execution order and the platform.

Attached patch changes:

* Replace get/restore methods with a Resource class and Resource subclasses
* Create ModuleAttr, ModuleAttrList and ModuleAttrDict helper classes
* Use __subclasses__() to get resource classes instead of using an hardcoded
  list (2 shutil resources were missinged in the list!)
* Don't define MultiprocessingProcessDangling resource if the multiprocessing module is missing
* Nicer diff for dictionaries. Useful for the big os.environ dict
* Reorder code to group resources


I chose to use classes to be able to easily customize how "Before/After" (value diff) is displayed: the new display_diff() method.

I also wrote helper classes to factorize the code.

Example:

    def get_sys_path(self):
        return id(sys.path), sys.path, sys.path[:]
    def restore_sys_path(self, saved_path):
        sys.path = saved_path[1]
        sys.path[:] = saved_path[2]

becomes

   class SysPath(ModuleAttrList):
       name = 'sys.path'

When sys.path is modified, currently Python displays the whole (id, object, object_copy) tuple which is not easily readable. With my change, it only displays object_copy (one list).

I began to write a pretty diff for ModuleAttrList, but it looks non trivial, and I'm not sure that it's worth (since lists are quite short).
History
Date User Action Args
2016-03-25 18:20:25vstinnersetrecipients: + vstinner, serhiy.storchaka
2016-03-25 18:20:24vstinnersetmessageid: <1458930024.17.0.00462396415924.issue26643@psf.upfronthosting.co.za>
2016-03-25 18:20:24vstinnerlinkissue26643 messages
2016-03-25 18:20:23vstinnercreate