I have a simple python unit test like this...
project/ calc/ calc.py calc_test.py
calc.py has two functions sum() and diff(), calc_test.py has two test cases to test those functions, using python inbuilt unittest framework.
I'm using Visual Studio code as my editor. If I set the top-level workspace as "project" directory, then VS Code fails the discover any tests. However, if reopen VS Code under "calc" directory, then it identifies the tests and displays nice overlays ("Run test", "Debug Test" etc..).
If I move the unit tests one level above (to proj/), then it works too. My recollection is that the argument "-s" and the directory "." should look for "test.py" files recursively from the top level directory where "python -m unittest <..>" command is run.
"python.unitTest.unittestEnabled": true,
"python.unitTest.unittestArgs": [
"-v",
"-s",
".",
"-p",
"*test*.py"
],
From proj/ I manually ran "python -m unittest discover -s . -p "test.py" -v, the tests were discovered and ran without any issues. I suppose VS Code should also be running similar commands internally, but something is missing here.
This makes it look like that VS Code fails to look for tests recursively from the top directory. I was about to open a issue at the Python extension for VS Code (https://github.com/Microsoft/vscode-python/issues/new), but wanted to check here first as per contribution guidelines.