I have been converting some tests written earlier for Unittest and am having trouble with import statements when running them with Pytest.
As an example, in the older code the module create.py
in directory lib
might be imported as
import lib.create
but this syntax usually raises errors when I run the code with Pytest.
The solution is include a setup.py
file at the top-level directory of the project, and then to use pip
to install it in "editable mode":
pip install -e .
That will generate a directory whose name ends in .egg-info
and which contains a number of configuration files. After that, running with Pytest takes place without difficulties.
I have posted a minimal working example here.
[end]
Comments are enabled.