"Test framework pytest is not installed. Install?" even though it *is* installed.
See original GitHub issueI have a workspace with the following:
- valid tests
- pytest installed in the configured interpreter
- pytest configured in the workspace settings
With the most recent insiders build of the extension I clicked on the “Discover Tests” button in the test explorer. A window popped up saying Test framework pytest is not installed. Install?
I verified that pytest was indeed really installed for the current interpreter. Then I looked at the “Python Test Log” Output panel. It showed that pytest discovery had failed (due to a import errors in my test files).
So when pytest discovery fails, the extension is erroneously acting as though pytest hasn’t been installed yet.
Given that pytest discovered most of the tests, I would have expected those tests to show up in the test explorer. I would also have expected a warning to pop up saying that there was a failure during test discovery (with a button to open the “Python Test Log” panel).
Issue Analytics
- State:
- Created 4 years ago
- Reactions:16
- Comments:10 (4 by maintainers)
Top GitHub Comments
Per @DonJayamanne, this is because the extension looks for “ModuleNotFoundError” (or “ImportError”?) in the output to decide if pytest is installed or not. Apparently that is too naive.
I confirm ericsnowcurrently’s diagnosis. I wasted full working day installing-reinstalling-purging-installing again pytest, python, conda, vscode… I just had bad luck in that my test was failing because of the missing module…
Please note, that my “bad luck” is actually a very probable scenario caused by another usability problem: when you write a unit test in
pytest
, just importing the module you want to test withimport tobetested
at the beginning of the test file does not work, and triggers theModuleNotFoundError: No module named 'tobetested'
error… then you are bombarded with the apparent problem with thepytest
installation…