[issue34200] importlib: python -m test test_pkg fails semi-randomly

Gregory P. Smith report at bugs.python.org
Wed Sep 12 19:53:09 EDT 2018


Gregory P. Smith <greg at krypto.org> added the comment:

I can make the test reliable... but I wouldn't say I fully understand the ultimate cause of the problem.

The reliability fix for test_pkg is to stop using test.support.modules_setup() and test.support.modules_cleanup() in the setUp() and tearDown() methods.

these test support functions are semi scary.  they attempt to backup and replace sys.modules contents with special case code in the cleanup function to try and avoid doing that to things that are still necessary.

running python -vvv when I could get test_pkg to fail led me looking at code paths that were being executed mid-test that i'd expect to be executed only on process startup.  locale.getpreferredencoding triggering a _bootlocale import, etc.  I don't understand why it cause the problem though.

PR to at least make the test reliable coming.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34200>
_______________________________________


More information about the Python-bugs-list mailing list