After trying all solutions online (like reinstalling python, checking if discovery works from the terminal, adding or removing __init__.py
files, deleting all __pycache__
folders,...) VSC still doesn't discover any test and, what's worse, there is no error message or anything... simply silent failing. Pytest, from the command line, works as expected.
VSC runs the following command (which doesn't add any test or recognizes any in the UI):
conda run -n azureml_py38 --no-capture-output python ~/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/get_output_via_markers.py ~/.vscode-server/extensions/ms-python.python-2022.14.0/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir . -s --cache-clear
When I run it in my terminal, I get:
>>>PYTHON-EXEC-OUTPUT
[{"rootid": ".", "root": "/mnt/batch/tasks/.../PROJECTFOLDER", "parents": [{"id": "./tests", "kind": "folder", "name": "tests", "parentid": ".", "relpath": "./tests"}, {"id": …
<<<PYTHON-EXEC-OUTPUT
so it looks as if the command is right and the tests can be discovered. My folder structure is simple:
├─.vscode/
│ └─ settings.json
├─src/
│ ├─ __init__.py
│ └─ module_A/
│ ├─ __init__.py
│ └─ code.py
└─tests/
├─ __init__.py
└─ unit_tests/
└─ test_code.py
My settings.json
is basically:
{
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.envFile": "${workspaceFolder}/.env"
}
and in my .env
file there's only PYTHONPATH=.
My versions are:
- vscode version: 1.71.2
- pytest version: 7.1.0
- python extension version: v2022.14.0
Any ideas?