[issue7559] TestLoader.loadTestsFromName swallows import errors

Robert Collins report at bugs.python.org
Mon Dec 21 23:28:44 CET 2009

Robert Collins <robertc at robertcollins.net> added the comment:

mkdir thing
touch thing/__init__.py
echo "import blert" > thing/test_foo.py
python -m unittest thing.test_fooTraceback (most recent call last):
  File "/usr/lib/python2.6/runpy.py", line 122, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.6/runpy.py", line 34, in _run_code
    exec code in run_globals
  File "/usr/lib/python2.6/unittest.py", line 875, in <module>
  File "/usr/lib/python2.6/unittest.py", line 816, in __init__
  File "/usr/lib/python2.6/unittest.py", line 843, in parseArgs
  File "/usr/lib/python2.6/unittest.py", line 849, in createTests
  File "/usr/lib/python2.6/unittest.py", line 613, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/lib/python2.6/unittest.py", line 584, in loadTestsFromName
    parent, obj = obj, getattr(obj, part)
AttributeError: 'module' object has no attribute 'test_foo'


Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list