I am trying to get my unit tests to show up in VSCode's test explorer, but it does not seem to be working. The test discovery does not fail with any errors in the output, but also does not show any of my tests.
This is the repo I am working in, you can see the file structure there.
This may or may not have anything to do with me using poetry to manage my virtual environment, though I'm sure the python interpreter is set correctly. I can get my tests to run perfectly well manually by running pytest
or poetry run pytest
in my base directory. I do have an empty __init__.py
in my tests directory. Also of note is that I'm running in Ubuntu on WSL 2.
I set this up environment with the following process:
- Install WSL2 on Windows
- Install VSCode on Windows
- Install the 'Remote - WSL' VSCode extension
- Open a new WSL Window in VSCode
- Install Anaconda in Ubuntu using this guide
- Install the VSCode Python extension
- Set the VSCode python interpreter to the anaconda install, and open a new terminal
pip install poetry
- Go to my project root folder
poetry install
- Set the VSCode python interpreter to the poetry environment, and open a new terminal
- Done, I can run pytest via the command line
Here's my workspace setting.json:
{
"restructuredtext.confPath": "${workspaceFolder}/docs/source",
"python.testing.pytestEnabled": true,
}
Here's what the output shows when I try to refresh tests:
~/.cache/pypoetry/virtualenvs/monaco-bfS1OgpY-py3.9/bin/python ~/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir ~/coding/monaco -s --cache-clear
cwd: ~/coding/monaco
If I run the above command manually in the terminal, it prints out a large dict which looks like it describes all my tests. (Below, truncated but it goes on like this for a while).
[{"rootid": ".", "root": "/mnt/c/Users/Scott/Documents/Documents/Coding/monaco", "parents": [{"id": "./tests", "kind": "folder", "name": "tests", "parentid": ".", "relpath": "./tests"}, {"id": "./tests/test_MCCase.py", "kind": "file", "name": "test_MCCase.py", "parentid": "./tests", "relpath": "./tests/test_MCCase.py"}, {"id": "./tests/test_MCSim.py", "kind": "file", "name": "test_MCSim.py", "parentid": "./tests", "relpath": "./tests/test_MCSim.py"}, {"id": "./tests/test_MCSim_io.py", "kind": "file", "name": "test_MCSim_io.py", "parentid": "./tests", "relpath": "./tests/test_MCSim_io.py"}, {"id": "./tests/test_MCVal.py", "kind": "file", "name": "test_MCVal.py", "parentid": "./tests", "relpath": "./tests/test_MCVal.py"},