Unittests not showing up in VS Code Testing Tab for exercism challenges

This may be slightly off topic but not unrelated to excersim so I hope I moght get some help from here.
Tests not showing up in VS Code Testing Tab for Python on WSL2.

I’m currently working on Python exercises on Exercism locally and have been running tests using VS Code’s Testing Tab. However, recently the tests stopped showing up even though they are located in the correct folder ~/exercism/python/**/*_test.py.

I tried deleting the .vscode-server files and reinstalling VS Code, but that didn’t help. I also updated the .vscode/settings.json file with the suggested code, but the tests are still not showing up in the Testing Tab. I even tried running the tests using the command “python -m unittest discover -v -s “./python” -p “**/*_test.py””, but it only shows the message “Ran 0 tests in 0.000s OK”.

I would appreciate any suggestions on how to resolve this issue and get the tests to show up in the Testing Tab on VS Code.

I did not know about any Testing tab in VS Code. I may look for it later today.

In the meantime: you do know that you can open the file with the tests just like the exercise file, and that you can run the tests from the command line?

@SafwanAmin-BracU – We use pytest and not unittest for our test runner. Please see these docs for what we suggest installing locally.

While we do use unittest syntax for many of our test files, we have a set of exercises (what we call ‘learning’ exercises) that rely on pytest features. This may or may not be part of your issue.

We also have inconsistent use of:

if __name__ == "__main__":

Which could effect whether or not the test file is discoverable. We’re working on removing these from files, but haven’t caught/gotten them all yet.

Finally, we have plans in the future to convert our existing tests to pytest syntax. When that happens, invoking unittest by itself will no longer work for any file. To avoid confusion, we recommend that students use pytest from the start.

I am not a power user of VSCode, and I typically run tests from a docker container or command line. But a search turned up these docs and this extension for pytest in VSCode.

I hope some of that helps.