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 <rep...@bugs.python.org>
<http://bugs.python.org/issue19013>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to