I have a directory structure like the following:
project/
README.md
project/
foobar/
foo.py
tests/
test_foo.py
test_foo
is just from foobar import foo
and when I run py.test
or just python3 tests/test_foo.py
from the project
subdirectory, I get a No module named foobar
error. I tried the other answers here such as adding ..
to sys.path
, using relative imports, none work, except when running python3 test_foo.py
inside tests
with sys.path.append('..')
.