question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Test framework pytest is not installed. Install?" even though it *is* installed.

See original GitHub issue

I 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:closed
  • Created 4 years ago
  • Reactions:16
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
ericsnowcurrentlycommented, Jul 15, 2019

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.

1reaction
adamryczkowskicommented, 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 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…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Py.test command not found, but library is installed
I have installed pytest via pip install pytest . I am able to import the library in Python as well. The problem is...
Read more >
Get Started — pytest documentation
pytest requires: Python 3.7+ or PyPy3. Run the following command in your command line: pip install -U pytest. Check that you installed the...
Read more >
Settings Reference for Python - Visual Studio Code
The Python extension uses this setting to install packages when Poetry is ... When debugging tests with pytest-cov installed, include --no-cov in these ......
Read more >
ModuleNotFoundError: No module named 'pytest' in Python
After installing the pytest module, you should be able to run your test file as pytest your_module.py . For example, here is a...
Read more >
PyTest Tutorial #1 - What is PyTest | How to Install PyTest
PyTest framework makes it easy to write small tests, yet scales to ... Installing PyTest is very simple and can be done in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found