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.

Cannot discover with pytest in 2020-01

See original GitHub issue

Environment data

  • VS Code version: 1.41.1
  • Extension version (available under the Extensions sidebar): 2020.1.57204 (6 January 2020)
  • OS and version: windows 10
  • Python version (& distribution if applicable, e.g. Anaconda): python 3.7.5
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): conda
  • Relevant/affected Python packages and their versions: pytest version 5.3.2
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info #3977): Language Server

Expected behaviour

The test are discovered

Actual behaviour

Since updating to the version 2020.1 I have the following two problems when discovering the tests with pytest:

  • The base environment does not have pytest installed, using a different environment with pytest installed I get the following output:
python c:\Users\Federico\.vscode\extensions\ms-python.python-2020.1.57204\pythonFiles\testing_tools\run_adapter.py discover pytest -- --rootdir c:\Users\Federico\Documents\GitHub\pytest-error -s --cache-clear
Test Discovery failed: 
Error: The system cannot find the path specified.

Traceback (most recent call last):

  File "c:\Users\Federico\.vscode\extensions\ms-python.python-2020.1.57204\pythonFiles\testing_tools\run_adapter.py", line 13, in <module>

    from testing_tools.adapter.__main__ import parse_args, main

  File "c:\Users\Federico\.vscode\extensions\ms-python.python-2020.1.57204\pythonFiles\testing_tools\adapter\__main__.py", line 9, in <module>

    from . import pytest, report

  File "c:\Users\Federico\.vscode\extensions\ms-python.python-2020.1.57204\pythonFiles\testing_tools\adapter\pytest\__init__.py", line 7, in <module>

    from ._discovery import discover

  File "c:\Users\Federico\.vscode\extensions\ms-python.python-2020.1.57204\pythonFiles\testing_tools\adapter\pytest\_discovery.py", line 8, in <module>

    import pytest

ModuleNotFoundError: No module named 'pytest'
  • with pytest installed in the base environment (using the base envornment or any other with pytest) I get the following error
python c:\Users\Federico\.vscode\extensions\ms-python.python-2020.1.57204\pythonFiles\testing_tools\run_adapter.py discover pytest -- --rootdir c:\Users\Federico\Documents\GitHub\pytest-error -s --cache-clear
Test Discovery failed: 
Error: The system cannot find the path specified.

Steps to reproduce:

  1. create a base environment, do no install pytest
  2. create a different environmnet, install pytest
  3. Clone the repo https://github.com/CaselIT/vscode-python-pytest-error
  4. open in vscode and select the environment with pytest installed
  5. should get the first error
  6. try installing pytest in the base environment
  7. should get the second error

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:16

github_iconTop GitHub Comments

2reactions
karrtikrcommented, Jan 10, 2020

We plan to release it on Monday. The version would start with 2020.1 Glad you got it working. Having non existing paths seemed to be the problem + using conda run seems to give rise to this issue. Previous version of the extension was not using conda run, so you didn’t face the issue. Closing this now.

0reactions
CaselITcommented, Jan 10, 2020

But it just did 😃

so the problem is with conda or the extension… It’s the first time I’ve had any problem regarding not existing folders on the path. Regardless of who’s the blame, there is no point continuing this, if I have other problems when the extension is updated I’ll open a new issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

pytest cannot find module - python - Stack Overflow
What happens here: when pytest discovers a conftest.py , it modifies sys.path so it can import stuff from the conftest module. So, since...
Read more >
Why does PyCharm not run pytest testing for my application?
I'm new to pytest and am trying to write testing modules for my application. My directory structure is: broker/ broker/tests...
Read more >
Changelog — pytest documentation
This is a fix to match a similar change made to test collection itself in pytest 6.0 (see pull request #6523 for details)....
Read more >
Changelog — pytest-benchmark 4.0.0 documentation
PerformanceRegression exception no longer inherits pytest.UsageError (apparently a final class). 3.2.3 (2020-01-10)¶. Fixed “ ...
Read more >
Apache Airflow testing with Pytest
For more details, please see the documentation ... and also ensures that tests can't affect anything in the default directory, ...
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