There are lots of similar questions (e.g. 1, 2, 3, 4, 5, 6, …) but none have quite this combination of issues (i.e. the unittest discovery working at the shell prompt), and the solutions to those questions have not worked for me.
When I run Python: Discover Tests
in Visual Studio Code I get the error
No tests discovered, please check the configuration settings for the tests.
My settings.json file looks like this
{
"python.testing.unittestArgs": [
"--verbose",
"--start-directory",
"./preprocessing/",
"--pattern",
"test_*.py"
],
"python.testing.pytestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.unittestEnabled": true
}
But I know the unittests are discoverable, because if I run this command from the root of my project all the tests are discovered and run:
python -m unittest discover --verbose --start-directory "./preprocessing/" --pattern "test_*.py"
My tests clearly are discoverable by Python's unittest framework, but VS Code does not find them. How might I fix this?