I am using VScode with python code and I have a folder with sub-directories (2-levels deep) containing python tests.
When I try "Python: Discover Tests" it asks for a test framework (selected pytest) and the directory in which tests exist. At this option, it shows only the top-level directories and does not allow to select a sub-directory.
I tried to type the directory path but it does not accept it.
Can someone please help on how to achieve this?
I solved it by putting this in my settings.json
:
"python.testing.cwd": "${workspaceFolder}/my-project/all-tests/unit-tests"
In the GUI, the setting name is "Python > Testing: Cwd".
If you then get the error No file or directory "unit-tests"
, try this:
pytest
or unittest
.
(Root Directory) - Earlier I had selected the unit-tests
directory insteadIf it still isn't working, you might be running into this open bug with ${workspaceFolder}
.
If it still isn't working, open up the "Output" window and select "Python" to see more info.
Also, this conversation was helpful: https://github.com/microsoft/vscode-python/issues/11587
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With