I am using py.test
to test my python code. The relevant structure of my project is
-myproject
file.py
file2.py
-test/
input.txt
input2.dat
test_part.py
-regress/
file2_old.py
__init__.py
-test/
test_file2_regression.py
test_part.py
imports file
and file2
and test_file2_regression.py
imports file2
and regress.file2_old
. If I run pytest
in the console, I get the import errors, that the packages don't exist. Running python -m pytest
on the other hand works perfectly fine, but only if I run it from the myproject/
directory.
What is the correct way to do this, to get it working from anywhere in my project? I already tried modifying the PYTHONPATH
but I honestly have no idea how to properly do it.
Further information:
I don't have any setup files, and my __init__
s are just empty files. If manipulating the PYTHONPATH
is necessary it needs to be done relative to myproject
as I use it on several machines. I am running python 2.7.
I already check out:
but it didn't really help me.