This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pitrou
Recipients berker.peksag, ezio.melotti, michael.foord, pitrou, python-dev
Date 2013-09-13.21:59:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1379109541.52.0.755301702969.issue19013@psf.upfronthosting.co.za>
In-reply-to
Content
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 :-(
History
Date User Action Args
2013-09-13 21:59:01pitrousetrecipients: + pitrou, ezio.melotti, michael.foord, python-dev, berker.peksag
2013-09-13 21:59:01pitrousetmessageid: <1379109541.52.0.755301702969.issue19013@psf.upfronthosting.co.za>
2013-09-13 21:59:01pitroulinkissue19013 messages
2013-09-13 21:59:01pitroucreate