I've been trying to make VSCodes test discovery (using pytest) find my test, but without success. The discovery fails, because pytest cannot resolve where my modules are coming from, hence I need to add the correct folder to the PYTHONPATH. Everything works nicely, when I use the terminal. I just export the correct PYTHONPATH and when I run "pytest" it works. However, I'm unable to make VSCode use that PYTHONPATH, when running the integrated test discovery. Using a ".env" file in the root folder, with the PYTHONPATH defined DOES NOT WORK (as suggested everywhere on the internet). Also what is suggested here: How to integrate VSCode with pytest ('test discovery fails')? also does not work.
My current workaround is to export the PYTHONPATH in the shell, start VSCode from that same shell session and then it works. I would like for it to just work with the ".env" file for example.
Is there a way?
EDIT:
Just figured out that adding a "pytest.ini" to the root folder, where I use the config "pythonpath" https://docs.pytest.org/en/latest/reference/reference.html#confval-pythonpath works as well. Still I find it highly frustrating that VSCode does not seem to use the ".env" file.