You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"Test framework pytest is not installed. Install?" even though it *is* installed. #5919
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).
Reacted by Joshua Winchester, Florin T., Keith Devens, Guy Waldman, Nathan B., Kyle Rich, Paulius Šarka, Erik Aaron Hansen, Kim, Jin (Jay@SKT), Oron Navon and 6 more
Per Don Jayamanne (@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 with import tobetested at the beginning of the test file does not work, and triggers the ModuleNotFoundError: No module named 'tobetested'error... then you are bombarded with the apparent problem with the pytest installation...
Check whether the module is installed using the code const isInstalled = await pythonExecutionService.isModuleInstalled(moduleName); instead of using isNotInstalledError
I've verified that the extension no longer says pytest isn't installed (even though it is). The text in "Python Test Log" output panel did not change (as expected).
Activity
ericsnowcurrently commentedon Jun 5, 2019
I've marked this as a regression, as I'm sure this wasn't a problem before.
ericsnowcurrently commentedon Jun 5, 2019
Here's the output from the "Python Test Log" Output panel:
ericsnowcurrently commentedon Jun 5, 2019
Per Don Jayamanne (@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.
ftrofin commentedon Jun 5, 2019
DonJayamanne commentedon Jun 5, 2019
ftrofin commentedon Jun 5, 2019
DonJayamanne commentedon Jun 5, 2019
adamryczkowski commentedon Jul 15, 2019
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 tobetestedat 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 thepytestinstallation...DonJayamanne commentedon Jul 17, 2019
Prescribed Solution
Check whether the module is installed using the code
const isInstalled = await pythonExecutionService.isModuleInstalled(moduleName);instead of usingisNotInstalledErrorericsnowcurrently commentedon Aug 1, 2019
I've verified that the extension no longer says pytest isn't installed (even though it is). The text in "Python Test Log" output panel did not change (as expected).