vscode-python: Cannot discover with pytest in 2020-01

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

About this issue

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

Most upvoted comments

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.