[Python-Dev] regrtest.py mystery
Tim Peters
tim.one@home.com
Sun, 16 Dec 2001 00:23:43 -0500
[Fred]
> Perhaps it should hold onto the module as well? That would avoid it
> getting cleaned up before possibly dependent modules.
> For the test case problem, perhaps there should be a list of
> exceptional modules that don't get cleaned up by regrtest once they
> appear. encodings and warnings would probably both need to be on the
> list. This list should probably be in the sys module; it would also
> be useful for the RollbackImporter in the unittestgui.py script that
> comes with the separate PyUnit package.
I expect the problem is intractable. Here's a revealing experiment: add
this block to the start of test___all__.check_all():
if modname in sys.modules:
del sys.modules[modname]
That is, just prior to test___all__ trying to import a module, remove *only*
that module from sys.modules if it's already there. Sounds pretty harmless,
right? But on Windows, it causes 28 standard tests to fail (possibly more
on Linux):
28 tests failed:
test___all__ test_difflib test_email test_fileinput test_fnmatch
test_future test_gettext test_glob test_global test_htmllib
test_htmlparser test_inspect test_mimetypes test_mmap test_os
test_pyclbr test_re test_regex test_repr test_scope test_sre
test_strftime test_strop test_sundry test_tokenize test_urllib2
test_xmllib test_xmlrpc
Trying to figure which modules "hurt" turns out to be a nightmare. Here's
the minimal set that allows the test suite to pass again on Windows, using
the default test order:
if modname in sys.modules:
if modname not in (
"copy_reg",
"os",
"sgmllib",
"sre",
"tempfile",
"tokenize",
"warnings",
):
del sys.modules[modname]
Am I gonna check that in? Fat chance <wink>.