lundi 25 juillet 2016

Python unittest fails to load modules when executed from command line

When I try to run python unittest from command line, in windows, I get the following error:

test_validateXml (unittest.loader.ModuleImportFailure) ... ERROR

consequently in the details there is an error message that reads:

Traceback (most recent call last):
   File "C:\Python27\lib\unittest\loader.py", line 254, in _find_tests
     module = self._get_module_from_name(name)
   File "C:\Python27\lib\unittest\loader.py", line 232, in _get_module_from_name
     __import__(name) 
from application.helpers.fileHelper import FileIO as fileIO 
ImportError: No module named application.helpers.fileHelper

The command I'm running is:

python -m unittest discover -v -p "*est*.py"

As I understand the reading I've done, all that's required in order to import modules is an __init__.py file in every directory of the project, which I have.

When I run the test from Visual Studio they run without any problems, any help is appreciated thanks.

Aucun commentaire:

Enregistrer un commentaire