[issue19013] unittest's own test suite is not CLI-friendly
Antoine Pitrou
report at bugs.python.org
Fri Sep 13 23:59:01 CEST 2013
Antoine Pitrou added the comment:
When trying to use a standard load_tests() inside a __main__.py, I get the following kind of errors:
======================================================================
ERROR: test_suite (unittest.loader.ModuleImportFailure)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/unittest/case.py", line 56, in testPartExecutor
yield
File "/home/antoine/cpython/default/Lib/unittest/case.py", line 496, in run
testMethod()
File "/home/antoine/cpython/default/Lib/unittest/loader.py", line 32, in testFailure
raise exception
ImportError: Failed to import test module: test_suite
Traceback (most recent call last):
File "/home/antoine/cpython/default/Lib/unittest/loader.py", line 272, in _find_tests
module = self._get_module_from_name(name)
File "/home/antoine/cpython/default/Lib/unittest/loader.py", line 250, in _get_module_from_name
__import__(name)
File "/home/antoine/cpython/default/Lib/unittest/test/test_suite.py", line 6, in <module>
from .support import LoggingResult, TestEquality
SystemError: Parent module '' not loaded, cannot perform relative import
... which means that loader.discover() doesn't try to import the test modules as part of their parent package, but as if they were standalone modules :-(
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19013>
_______________________________________
More information about the Python-bugs-list
mailing list