I'm a newcomer to Python and I'm struggling with getting the right project structure so that I can create a package and a separate tests
directory next to it for unit tests.
I've tried following the canonical format described at: http://ift.tt/1QpVKlb . Unfortunately even using the example on github I can't get that work:
python tests\test_basic.py
Traceback (most recent call last):
File "tests\test_basic.py", line 3, in <module>
from .context import sample
SystemError: Parent module '' not loaded, cannot perform relative import
python -m unittest
doesn't work either:
ERROR: sample (unittest.loader._FailedTest)
ImportError: Failed to import test module: sample
Traceback (most recent call last):
File "C:\ProgramData\chocolatey\lib\python3\tools\lib\unittest\loader.py", line 462, in _find_test_path
package = self._get_module_from_name(name)
File "C:\ProgramData\chocolatey\lib\python3\tools\lib\unittest\loader.py", line 369, in _get_module_from_name
__import__(name)
File "E:\source\python\samplemod\sample\__init__.py", line 1, in <module>
from .core import hmm
File "E:\source\python\samplemod\sample\core.py", line 9
print get_hmm()
^
SyntaxError: invalid syntax
EDIT: The following suggests that it's running tests but isn't (as verified by making the tests fail)
> python setup.py test
running test
Any idea what's going on here? If even the recommended format doesn't work then I'm high and dry... I'm on python 3.5.1 on Windows
Aucun commentaire:
Enregistrer un commentaire