Folders named 'py' result in "Test result not found"
See original GitHub issueEnvironment data
- VS Code version: 1.60.0
- Extension version (available under the Extensions sidebar): v2021.9.1230869389
- OS and version: MacOS 11.6
- Python version (& distribution if applicable, e.g. Anaconda): 3.9.1
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): pyenv
- Relevant/affected Python packages and their versions: pytest==6.2.5
- Value of the
python.languageServer
setting: Pylance
Expected behaviour
This simple test should appear succeeded in UI :
def test_passing():
assert 42 == 42
Actual behaviour
The test is failed (red circle) with this reason :
Steps to reproduce:
The issue is very similar to https://github.com/Microsoft/vscode-python/issues/17270 which is closed by https://github.com/microsoft/vscode-python/pull/17275
The only difference that in my case folder name is not starting with “py”, but the whole folder name is “py”:
- Have pytest installed and selected as a default test framework
- Put tests inside folder named “py”. For example, “./tests/py/”
- Try to execute test
- The test is executed correctly, but test UI shows error.
Logs
Output for Python
in the Output
panel (View
→Output
, change the drop-down the upper-right of the Output
panel to Python
)
> ~/.pyenv/versions/3.9.1/envs/vscode_python_pytest/bin/python -m pytest --rootdir ~/projects/vscode_python_pytest --override-ini junit_family=xunit1 --junit-xml=/var/folders/0_/6w94lk1171vc_fpwbjqx02nw0000gn/T/tmp-14897brlMlEUuYALH.xml ./tests/py/test_something.py::test_passing
cwd: ~/projects/vscode_python_pytest
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top Results From Across the Web
python - Py.test No module named
In my test_app.py file , I have a line to import my app module. When I run py.test on the root folder, I...
Read more >Usage and Invocations — pytest documentation
You can invoke testing through the Python interpreter from the command line: python -m pytest [. ... Running pytest can result in six...
Read more >ERROR: file or directory not found: tests/*
The error indicates that the tests folder does not exist in the repository. The pytest command expects to find files with tests in...
Read more >PublishTestResults@2 - Publish Test Results v2 task
Publish test results to Azure Pipelines. ... searches for all the XML files whose names start with TEST- in all subdirectories.
Read more >ModuleNotFoundError: no module named Python Error ...
This error comes as a result of the misspelled numpy module as nompy (with the letter o instead of u). You can fix...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@hszw-forpeople I recommend using an older version of the extension 2021.8.*, if you cannot change the name.
One more thing. It looks like parameter
--rootdir
in thepython.testing.pytestArgs
also affects behavior of test execution from the test explorer UI.Just want remind that it should be taken into account.
then tests are discovered, but if I try to execute those, then I am getting a message in Python Test Log:
ERROR: file or directory not found: ...
and the test I clicked continues to be displayed as gray (not executed)then test are discovered, but I am getting an error described in the first message in this issue:
Test result not found for: ...
and the test I clicked is turning red (as on the screenshot in the first post)