I just discovered that vscode is able to run pytest directly out of the editor. That's pretty awesome - if it would work.
Currently I'm working on a project within a virtual environment, which is properly configured in vscode (and activated). pytest is installed in the virtual environment and activated as well, the tests I wrote are discovered as expected. But whenever I run a test, it says, that it does not find the module I'm currently working on and a ModuleNotFoundError is raised.
I have installed this module with pip install -e .. Running the same tests on a normal terminal console outside vscode works like expected.
It does not make a difference if pytest is enabled for the workspache only and/or for the user.
Sample code:
def test_something():
from mymodule.config import Config
...
Output:
E ModuleNotFoundError: No module named 'mymodule'
Pip sample output:
mymodule 0.1.0 /path/to/mymodule
Stange is also, that vscode runs the correct pytest script (it is not installed globally, only in this environment) with all installed plugins (i.e. pytest-datafiles).
Any ideas why?
Regards, Thomas