VS Code works just fine when Run Test button (does not matter if via testing tab (left side) or by right click close to the test) but Debug Test button logs this error:
.
.
.
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/Users/xxx/.vscode/extensions/ms-python.python-2022.4.1/pythonFiles/testlauncher.py", line 44, in <module>
run(cwd, testRunner, args)
File "/Users/xxx/.vscode/extensions/ms-python.python-2022.4.1/pythonFiles/testlauncher.py", line 34, in run
import pytest
ModuleNotFoundError: No module named 'pytest'
settings.json
{
"python.testing.pytestArgs": [
"packages/xxxxxx/tests/unit/xxxxxx/xxxxx",
"-s",
],
"python.testing.pytestPath": "runtimes/.venv/xxxxxx/bin/pytest",
"python.testing.pytestEnabled": true,
"python.linting.pylintEnabled": false,
"python.linting.enabled": false,
"files.exclude": {
"**/*.pyc": true,
}
}
I went through this link: Tried the below suggestions, without any luck:
- Downgrade the Python extention to v2020.2.64397
- Include these lines into
launch.json:
{
"name": "Python: Test debug config",
"type": "python",
"request": "test",
"console": "integratedTerminal",
"logToFile": true
}