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.

Folders named 'py' result in "Test result not found"

See original GitHub issue

Environment 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 : image

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”: image

  1. Have pytest installed and selected as a default test framework
  2. Put tests inside folder named “py”. For example, “./tests/py/”
  3. Try to execute test
  4. The test is executed correctly, but test UI shows error.

Logs

Output for Python in the Output panel (ViewOutput, 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:open
  • Created 2 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
karthiknadigcommented, Oct 13, 2021

@hszw-forpeople I recommend using an older version of the extension 2021.8.*, if you cannot change the name.

1reaction
botsmancommented, Oct 8, 2021

One more thing. It looks like parameter --rootdir in the python.testing.pytestArgs also affects behavior of test execution from the test explorer UI.

Just want remind that it should be taken into account.

  1. If I use
"python.testing.pytestArgs": [
        "./tests/py"
    ]

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)

  1. If I use
"python.testing.pytestArgs": [
        "--rootdir",
        "./tests/py"
    ]

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)

Read more comments on GitHub >

github_iconTop 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 >

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