Closed benoitbryon closed 10 years ago
It is related to healthcheck discovery. https://docs.python.org/2.7/library/unittest.html#unittest.TestLoader.discover mentions:
All test modules must be importable from the top level of the project. If the start directory is not the top level directory then the top level directory must be specified separately.
But hospital's current implementation uses a start_dir that is outside project in some cases, as an example if you try to discover tests from standard library (try hospital-cli xml.etree
).
Here is another traceback, a bit different but related to bad loading of packages/modules outside working directory:
$ hospital-cli xml.etree
EE
======================================================================
ERROR: ElementTree (unittest.loader.ModuleImportFailure)
----------------------------------------------------------------------
ImportError: Failed to import test module: ElementTree
Traceback (most recent call last):
File "/usr/lib/python2.7/unittest/loader.py", line 254, in _find_tests
module = self._get_module_from_name(name)
File "/usr/lib/python2.7/unittest/loader.py", line 232, in _get_module_from_name
__import__(name)
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 127, in <module>
from . import ElementPath
ValueError: Attempted relative import in non-package
======================================================================
ERROR: ElementInclude (unittest.loader.ModuleImportFailure)
----------------------------------------------------------------------
ImportError: Failed to import test module: ElementInclude
Traceback (most recent call last):
File "/usr/lib/python2.7/unittest/loader.py", line 254, in _find_tests
module = self._get_module_from_name(name)
File "/usr/lib/python2.7/unittest/loader.py", line 232, in _get_module_from_name
__import__(name)
File "/usr/lib/python2.7/xml/etree/ElementInclude.py", line 52, in <module>
from . import ElementTree
ValueError: Attempted relative import in non-package
Here is a sample traceback.