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.

`python.testing.pytestPath` does not work with test discovery.

See original GitHub issue

Discussed in https://github.com/microsoft/vscode-python/discussions/19316

<div type='discussions-op-text'>

Originally posted by ProfessorCode212 June 16, 2022 I get the following uncaught error for the Python Extension in VS Code. This only happens inside venv. It doesn’t seem to be able to detect my system-wide pytest installation. I have even set python.testing.pytestPath to ~/.local/bin/pytest.

Traceback (most recent call last): 
File "/home/pc/.vscode/extensions/ms-python.python-2022.8.0/pythonFiles/testing_tools/run_adapter.py",
 line 17, in <module> from testing_tools.adapter.__main__ import parse_args,
 main File "/home/pc/.vscode/extensions/ms-python.python-2022.8.0/pythonFiles/testing_tools/adapter/__main__.py",
 line 9, in <module> from . import pytest,
 report File "/home/pc/.vscode/extensions/ms-python.python-2022.8.0/pythonFiles/testing_tools/adapter/pytest/__init__.py",
 line 7, in <module> from ._discovery import discover 
File "/home/pc/.vscode/extensions/ms-python.python-2022.8.0/pythonFiles/testing_tools/adapter/pytest/_discovery.py",
 line 8, in <module> import pytest
 ModuleNotFoundError: No module named 'pytest'

This problem does get fixed if I install pytest into the relevant venv but I am wondering if there is a way around it.</div>

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:17
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
brettcannoncommented, Aug 17, 2022

@gschaffner the classification won’t really affect how we address it since we are actively working on the testing code rewrite for pytest. I don’t think stopping that work to try and implement this or rip it out by treating like a bug is going to be the best use of anyone’s time on the team. If someone would like to propose a solution and submit a PR in the mean time, we would be willing to review it.

Regardless, I’ve added the bug label as well.

0reactions
ProfessorCode212commented, Aug 17, 2022

@gschaffner I believe they are currently trying to deprecate it, which is why this is categorized as a ‘feature request’. I agree, though, that this is a bug since there is no warning given for it and the setting is still half there in VS Code.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VSCode pytest test discovery fails - python - Stack Overflow
In my case the problem with vscode being unable to discover tests was the coverage module being enabled in the setup.cfg (alternatively this ......
Read more >
pytest does not respect 'pytestPath' on test discovery #8896
Issue Type: Bug pytest tests discovery fail with No module named 'pytest', although I have specified pytestPath. VS Code does not display ...
Read more >
Testing Python in Visual Studio Code
Unit tests are concerned only with the unit's interface—its arguments and return values—not with its implementation (which is why no code is shown...
Read more >
unittest — Unit testing framework — Python 3.11.1 ...
The unittest module can be used from the command line to run tests from modules ... Test discovery is implemented in TestLoader.discover() ,...
Read more >
pytest import mechanisms and sys.path / PYTHONPATH
Importing files in Python (at least until recently) is a non-trivial processes, ... the tests will run against the installed version of pkg_under_test...
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