New submission from STINNER Victor: (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). ---------- components: Tests files: save_env.patch keywords: patch messages: 262449 nosy: haypo, serhiy.storchaka priority: normal severity: normal status: open title: regrtest: rework libregrtest.save_env submodule versions: Python 3.6 Added file: http://bugs.python.org/file42293/save_env.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue26643> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com