[Python-Dev] regrtest.py mystery
Tim Peters
tim.one@home.com
Sat, 15 Dec 2001 16:20:32 -0500
We do this after running every test:
# Unload the newly imported modules (best effort finalization)
for module in sys.modules.keys():
if module not in save_modules and module.startswith("test."):
test_support.unload(module)
Unfortunately, that doesn't nuke whatever damaged non-test module objects
may have been left behind. If I change it to make a truly <wink> best
effort:
if module not in save_modules:
test_support.unload(module)
then about a dozen std tests fail in mysterious ways, but only when running
more than one test. Like just running
test_email test_string
causes test_string to die like so:
python ../lib/test/regrtest.py -v test_email test_string
...
test test_string crashed -- exceptions.AttributeError: 'NoneType' object
has no attribute 'get'
Traceback (most recent call last):
File "../lib/test/regrtest.py", line 305, in runtest
the_module = __import__(test, globals(), locals(), [])
File "../lib/test\test_string.py", line 34, in ?
string_tests.run_method_tests(test)
File "../lib/test\string_tests.py", line 233, in run_method_tests
verify('hello world'.encode('zlib') == data)
File "C:\CODE\PYTHON\lib\encodings\__init__.py", line 43, in
search_function
entry = _cache.get(encoding,_unknown)
AttributeError: 'NoneType' object has no attribute 'get'
It seems generally the case that these failures are due to various
module-level names getting rebound to None. A simpler example:
python ../lib/test/regrtest.py -v test_string test_string
...
test test_string crashed -- exceptions.AttributeError: 'NoneType' object
has no attribute 'compress'
Traceback (most recent call last):
File "../lib/test/regrtest.py", line 305, in runtest
the_module = __import__(test, globals(), locals(), [])
File "../lib/test\test_string.py", line 34, in ?
string_tests.run_method_tests(test)
File "../lib/test\string_tests.py", line 233, in run_method_tests
verify('hello world'.encode('zlib') == data)
File "C:\CODE\PYTHON\lib\encodings\zlib_codec.py", line 25, in zlib_encode
output = zlib.compress(input)
AttributeError: 'NoneType' object has no attribute 'compress'
What's up with that? So far, they all seem to involve the encodings
directory ...