I have two python scripts, x.py
and test_x.py
, I want to import x
from
test_x
.
x.py
is located at./foo/bar/baz/x.py
test_x.py
is located at./tests/test_x.py
Contents of x.py
def f(x):
return x + 1
Contents of test_x.py
import foo.bar.baz.x as x
def test_f():
assert x.f(1) == 2, "Error"
I then try running the above as:
pytest -m tests/test_x.py
Which gives me the error:
tests/test_x.py:1: in <module>
import foo.bar.baz.x as x
E ModuleNotFoundError: No module named 'foo'
So - how should I go about running the above test?