New submission from Daniel Waterworth <da.waterwo...@googlemail.com>:
The problem is that when you import a module which is inside a package via 'loadTestsFromName' in unittest.TestLoader. If the imported module raises a ImportError this is read to mean that the module itself is unavailable. To illustrate this I have a small test-case. First run the file runtests.py in python or python3. Next uncomment the first line in test/test.py and run again. The error I receive is: Traceback (most recent call last): File "runtests.py", line 3, in <module> suite = unittest.TestLoader().loadTestsFromName("test.test") File "/usr/lib/python2.6/unittest.py", line 584, in loadTestsFromName parent, obj = obj, getattr(obj, part) AttributeError: 'module' object has no attribute 'test' Whereas I believe this should raise an "ImportError: No module named none_existant_module", just like it does when you try to import the module directly. This would make the error more descriptive and therefore bugs of this nature easier to track down. ---------- components: Library (Lib) files: testcase.tar.bz2 messages: 98997 nosy: Daniel.Waterworth severity: normal status: open title: Incorrect error raised on importing invalid module via unittest type: behavior versions: Python 3.1 Added file: http://bugs.python.org/file16166/testcase.tar.bz2 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue7872> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com