Skip to content
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

Testing tool does not find globally installed pytest, but VSCode terminal does. #17320

Closed
ghost opened this issue Sep 8, 2021 · 3 comments
Closed
Assignees
Labels
area-testing bug Issue identified by VS Code Team member as probable bug

Comments

@ghost
Copy link

ghost commented Sep 8, 2021

Environment data

  • VS Code version: 1.60.0
  • OS and version: Windows 10
  • Python version (& distribution if applicable, e.g. Anaconda): 3.9
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): venv
  • Relevant/affected Python packages and their versions: pytest
  • Value of the python.languageServer setting: Default

Expected behaviour

pytest is installed globally, not in the .venv of the project, and its path is added to python.testing.pytestPath.
When calling pytest in a VSCode terminal, with .venv activated, the tests run correctly.

Using the Testing menu should call pytest from the path entered in python.testing.pytestPath and return a similar result to what I obtain from terminal.

Actual behaviour

The Testing tool says Error discovering pytest tests (see Output > Python).
Output shows:

Error 2021-09-08 17:22:58: Error discovering pytest tests:
 [r [Error]: Traceback (most recent call last):
  File "c:\Users\xxx\.vscode\extensions\ms-python.python-2021.9.1191016588\pythonFiles\testing_tools\run_adapter.py", line 17, in <module>
    from testing_tools.adapter.__main__ import parse_args, main
  File "c:\Users\xxx\.vscode\extensions\ms-python.python-2021.9.1191016588\pythonFiles\testing_tools\adapter\__main__.py", line 9, in <module>
    from . import pytest, report
  File "c:\Users\xxx\.vscode\extensions\ms-python.python-2021.9.1191016588\pythonFiles\testing_tools\adapter\pytest\__init__.py", line 7, in <module>
    from ._discovery import discover
  File "c:\Users\xxx\.vscode\extensions\ms-python.python-2021.9.1191016588\pythonFiles\testing_tools\adapter\pytest\_discovery.py", line 8, in <module>
    import pytest
ModuleNotFoundError: No module named 'pytest'

	at ChildProcess.<anonymous> (c:\Users\xxx\.vscode\extensions\ms-python.python-2021.9.1191016588\out\client\extension.js:9:380706)
	at Object.onceWrapper (events.js:422:26)
	at ChildProcess.emit (events.js:315:20)
	at maybeClose (internal/child_process.js:1048:16)
	at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)]
@ghost ghost added bug Issue identified by VS Code Team member as probable bug triage-needed Needs assignment to the proper sub-team labels Sep 8, 2021
@rlittlefield
Copy link

I'm seeing something similar. I reverted my extension to 2021.6.944021595 and it seems to respect my pytestPath and pytestArgs again.

@karthiknadig karthiknadig self-assigned this Sep 8, 2021
@karthiknadig karthiknadig added area-testing triage and removed triage-needed Needs assignment to the proper sub-team labels Sep 8, 2021
@ghost
Copy link
Author

ghost commented Sep 9, 2021

For information, it does work properly if I install pytest in the virtual env.

@karthiknadig
Copy link
Member

Looks like pytestPath was only honored when running tests. But not always when discovering tests, it may work sometimes but that was not by design. We are currently working on re-writing the test adapter, and we will handle these scenarios there.

Closing in favor of #17242

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 27, 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
Projects
None yet
Development

No branches or pull requests

2 participants