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.

Pytest discovery fails with Miniconda installation [Windows]

See original GitHub issue

Environment data

  • VS Code version: Version: 1.34.0-insider (system setup)
  • Extension version (available under the Extensions sidebar): 2019.4.11881 Publisher: Microsoft
  • OS and version: 7 SP1 and up
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7.3 Miniconda install
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): conda
  • Relevant/affected Python packages and their versions: pytest 4.x, currently on 4.4.1

Expected behaviour

I expect pytest to be discovered and used when I select “Run Tests”

Actual behaviour

Pytest isn’t discovered.

Steps to reproduce:

  1. Install Miniconda3, python version shouldn’t matter but I use 3.
  2. Install VS Code
  3. Install the Python extension
  4. Specify Miniconda path in Settings (even though this should be technically unnecessary due to global environment variables set in Windows)
  5. Create a python file, can be as simple as “Hello World!”.
  6. Select “Run Test”, Select “Discover Unit Tests” from command palette dropdown.
  7. No tests are discovered so prompt appears to configure test framework. Select pytest and choose default path (Root directory).

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

None provided for pytest discovery. Generic output as follows:

Starting Microsoft Python language server. [Info - 3:31:30 PM] GetCurrentSearchPaths C:\ProgramData\Miniconda3\python.exe [Info - 3:31:31 PM] Python search paths: [Info - 3:31:31 PM] c:\programdata\miniconda3\dlls [Info - 3:31:31 PM] c:\programdata\miniconda3\lib [Info - 3:31:31 PM] c:\programdata\miniconda3 [Info - 3:31:31 PM] c:\programdata\miniconda3\lib\site-packages [Info - 3:31:31 PM] c:\programdata\miniconda3\lib\site-packages\win32 [Info - 3:31:31 PM] c:\programdata\miniconda3\lib\site-packages\win32\lib [Info - 3:31:31 PM] c:\programdata\miniconda3\lib\site-packages\pythonwin [Info - 3:31:31 PM] Configuration search paths:

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging)

Nothing about discovering pytest shown.

Edit: I do want to note that pylint works just fine so that’s getting detected. So whatever code is checking the path to pylint needs to be applied for pytest.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:7

github_iconTop GitHub Comments

1reaction
WSLUsercommented, Apr 25, 2019

Well I guess it took an extremely long time to load but I finally have something in Python Test Log

Test Discovery failed: 
Error: Traceback (most recent call last):
  File "c:\Users\user\.vscode-insiders\extensions\ms-python.python-2019.4.11881\pythonFiles\testing_tools\run_adapter.py", line 16, in <module>
    main(tool, cmd, subargs, toolargs)
  File "c:\Users\user\.vscode-insiders\extensions\ms-python.python-2019.4.11881\pythonFiles\testing_tools\adapter\__main__.py", line 90, in main
    parents, result = run(toolargs, **subargs)
  File "c:\Users\user\.vscode-insiders\extensions\ms-python.python-2019.4.11881\pythonFiles\testing_tools\adapter\pytest.py", line 43, in discover
    raise Exception('pytest discovery failed (exit code {})'.format(ec))
Exception: pytest discovery failed (exit code 2)
0reactions
DonJayamannecommented, May 15, 2019

@WSLUser This should now work in the latest version of the extension.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VSCode pytest test discovery fails - python - Stack Overflow
I am using a src format in my workspace and Conda for environment management. The settings related to the terminal setup keep me...
Read more >
Set up unit testing for Python code - Visual Studio
Setting up unit testing for Python code in Visual Studio takes full advantage of Test Explorer features to discover, run, and debug tests....
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 >
Package installation issues | PyCharm Documentation
You might encounter a problem when installing a Python package in the project settings ... Fail to install a package on a Conda...
Read more >
Configuration & API — Nox 2022.11.21 documentation
Install invokes pip to install packages inside of the session's virtualenv. To install packages directly: session.install('pytest') ...
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