Message262449
(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). |
|
Date |
User |
Action |
Args |
2016-03-25 18:20:25 | vstinner | set | recipients:
+ vstinner, serhiy.storchaka |
2016-03-25 18:20:24 | vstinner | set | messageid: <1458930024.17.0.00462396415924.issue26643@psf.upfronthosting.co.za> |
2016-03-25 18:20:24 | vstinner | link | issue26643 messages |
2016-03-25 18:20:23 | vstinner | create | |
|