Skip to content

Extension shows install pytest prompt when test discovery fails due to missing some another module #5730

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
karthiknadig opened this issue May 22, 2019 · 3 comments
Labels
area-testing bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Milestone

Comments

@karthiknadig
Copy link
Member

Environment data

  • VS Code version: 1.34.0
  • Extension version (available under the Extensions sidebar): 2019.6.16302-dev
  • OS and version: windows
  • Python version (& distribution if applicable, e.g. Anaconda): 3.7
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Relevant/affected Python packages and their versions: pytest

Expected behaviour

Should not show pytest install prompt, if pytest is installed. Insted say test discovery failed.
Bonus points if it can identify which module is actually missing ans show the right prompt.

Actual behaviour

image

Steps to reproduce:

  1. Use these settings:
{
    "python.pythonPath": "C:\\Python37\\python.exe",
    "python.testing.pyTestEnabled": true,
    "python.testing.nosetestsEnabled": false,
    "python.testing.unittestEnabled": false,
    "python.testing.pyTestArgs": [
        "."
    ],
}
  1. Add a file in root dir that imports some module that is not installed.
    pyqt_test.py:
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *

# this is enough to get the prompt.

Logs

______________________ ERROR collecting pyqtapp_test.py _______________________
ImportError while importing test module 'c:\GIT\pyscratch2\pyqtapp_test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
pyqtapp_test.py:1: in <module>
    from PyQt5.QtGui import *
E   ModuleNotFoundError: No module named 'PyQt5'
!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!
=========================== 1 error in 0.10 seconds ===========================

Traceback (most recent call last):
  File "C:\Users\kanadig\.vscode\extensions\ms-python.python-2019.6.16302-dev\pythonFiles\testing_tools\run_adapter.py", line 16, in <module>
    main(tool, cmd, subargs, toolargs)
  File "C:\Users\kanadig\.vscode\extensions\ms-python.python-2019.6.16302-dev\pythonFiles\testing_tools\adapter\__main__.py", line 90, in main
    parents, result = run(toolargs, **subargs)
  File "C:\Users\kanadig\.vscode\extensions\ms-python.python-2019.6.16302-dev\pythonFiles\testing_tools\adapter\pytest\_discovery.py", line 35, in discover
    raise Exception('pytest discovery failed (exit code {})'.format(ec))
Exception: pytest discovery failed (exit code 2)
@ghost ghost added the triage-needed Needs assignment to the proper sub-team label May 22, 2019
@DonJayamanne DonJayamanne added area-testing needs PR bug Issue identified by VS Code Team member as probable bug labels May 22, 2019
@ghost ghost removed triage-needed Needs assignment to the proper sub-team labels May 22, 2019
@erihanse
Copy link

erihanse commented Jul 11, 2019

I have the same problem, except that it only fails for my own modules. If I install version 2019.3.6558 of the extension it works, and tests are discovered.

EDIT:
The latest version I got it to work with was 2019.5.x.
After reading this thread: #6347 (comment) I realised normal behaviour would be resolved by adding an .env file containing PYTHONPATH=..

@warnes
Copy link

warnes commented Jul 12, 2019

I can confirm this error for myself and several colleagues.

@karrtikr
Copy link

Fixed with latest extension.

@karrtikr karrtikr added this to the October 2021 milestone Oct 21, 2021
@karrtikr karrtikr added the verified Verification succeeded label Oct 25, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-testing bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

5 participants