Reputation: 434
This is a broad question because no one seems to have found a solution to it as yet so I think asking to see a working example might prove more useful. So here goes:
Has anyone run a nosetests on a python project using imports of multiple files/packages?
What I mean is, do you have a directory listing such as:
project/
|
|____app/
|___main.py
|___2ndFile.py
|___3rdFile.py
|____tests/
|____main_tests.py
Where your main.py imports multiple files and you perform a nosetests from the project file of utilizing a test script in the main_tests.py file? If so please can you screen shot your import section both of all your main files and your main_tests.py file?
This seems to be a major issue in nosetests, with no apparent solution:
Upvotes: 1
Views: 997
Reputation: 362836
2ndFile.py
, 3rdFile.py
won't actually work (rename them). __init__.py
inside the app directory, for it to be considered a package, so add that (it can be empty file). __init__.py
in the tests directory!main_tests.py
should look like from app.main import blah
project
directory needs to be in your sys.path
. To achieve this, set an environment variable: export PYTHONPATH=/path/to/project
Now running nosetests should work.
Upvotes: 2