I literally just had Pytest working fine, I have the correct conda env selected in VSCode. I tried to run a test just then, and it can’t find my folder ‘modules’ which is in my project directory. The import for modules is in my tests/test_function.py file, as:
from modules.my_module import my_func
[pytest]
testpaths = tests
python_files = test_*.py
addopts = -v -s
filterwarnings =
ignore::DeprecationWarning
ignore::UserWarning
ignore::RuntimeWarning
Above is my pytest.ini file.
"python.testing.pytestArgs": [
"tests",
"-s"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.testing.autoTestDiscoverOnSaveEnabled": true,
"python.testing.pytestPath": "pytest",
"python.analysis.extraPaths": ["."]
I’ve tried adding the above to my user settings in VSCode.
If I run pytest from command line (same conda env):
python -m pytest tests/test_function.py::test_myfunc -v
It works totally fine. And, VSCode worked fine 5 minutes ago, I haven’t changed a thing. I tried restarting VSCode.
What have I done wrong here? I’m losing my mind and I keep running into these type of problems with Python imports, and I end up spending four hours figuring it out instead of actually working. Thanks!!
1