testingvisual-studio-codepytest

Visual Studio Code test sidebar button disappeared


In Visual Studio Code, the test button on the left, the one that looks like a flask, has disappeared on my machine. I tried to run the command "Test: Run All Tests", but I get a message "No tests found in this workspace. You may need to install a test provider extension". Did I just accidentally uninstall test support in VSCode? I can still run pytest from the command line and that works fine.


Solution

  • OK I found out the problem myself. It seems that there is another Python executable on my Windows machine, which seems to have come with VSCode itself, at C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\python.exe. Somehow when I restarted VSCode, that Python executable was selected, and it didn't have pytest or even unittest or anything I don't think, so I guess VSCode saw that there was no testing capability at all and didn't bother showing the test button. It seems insane that VSCode comes with its own Python executable though, I wonder why that is.

    EDIT Oh oops it's Visual Studio that came with the Python executable, not VSCode, obviously as the path suggests. My bad.