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.

When debugging pytest tests, extension displays "Ok" in the problems window

See original GitHub issue

Environment data

  • VS Code version: GH Codespaces
  • Extension version (available under the Extensions sidebar): 2020.11.371526539
  • Python version (& distribution if applicable, e.g. Anaconda): 3.9.0
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): None
  • Relevant/affected Python packages and their versions: pytest==6.1.2
  • Relevant/affected Python-related VS Code extensions and their versions: Pylance 2020.11.2
  • Value of the python.languageServer setting Pylance

[NOTE: If you suspect that your issue is related to the Microsoft Python Language Server (python.languageServer: 'Microsoft'), please download our new language server Pylance from the VS Code marketplace to see if that fixes your issue]

Actual behaviour

When starting to debug a test with pytest, this is the message displayed by pytest: image

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

  1. Start a GH Codespace for https://github.com/microsoft/python-sample-tweeterapp, make sure to use the fixwarnings branch.
  2. Run python manage.py migrate and python manage.py loaddata initial_data in the terminal
  3. Configure tests by running the “Python: Configure Tests” command. Select “pytest” and then “tweeter”.
  4. Open the test viewer and debug a test.

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

User belongs to experiment group 'ShowPlayIcon - start'
User belongs to experiment group 'ShowExtensionSurveyPrompt - control'
User belongs to experiment group 'DebugAdapterFactory - experiment'
User belongs to experiment group 'PtvsdWheels37 - experiment'
User belongs to experiment group 'UseTerminalToGetActivatedEnvVars - control'
User belongs to experiment group 'LocalZMQKernel - experiment'
User belongs to experiment group 'CollectLSRequestTiming - control'
User belongs to experiment group 'CollectNodeLSRequestTiming - experiment'
User belongs to experiment group 'EnableIPyWidgets - experiment'
User belongs to experiment group 'RunByLine - experiment'
User belongs to experiment group 'CustomEditorSupport - control'
> conda --version
> conda info --json
> pyenv root
> python3.7 ~/.vscode-remote/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python3.6 ~/.vscode-remote/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python3 ~/.vscode-remote/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python2 ~/.vscode-remote/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> python ~/.vscode-remote/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
> /usr/local/bin/python ~/.vscode-remote/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
Error 2020-12-02 08:59:46: Failed to check if file needs to be fixed EntryNotFound (FileSystemError): Unable to read file 'vscode-remote://vsonline+f206027f-0efb-4a62-b3ad-cdca607daff2/root/.config/Code - Insiders/User/settings.json' (EntryNotFound (FileSystemError): Error: ENOENT: no such file or directory, open '/root/.config/Code - Insiders/User/settings.json')
    at _handleError (/root/.vscode-remote/bin/bf21395291146c014220eb70b54fdfc0a15956b5/out/vs/server/remoteExtensionHostProcess.js:765:473)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)
    at y.readText (/root/.vscode-remote/extensions/ms-python.python-2020.11.371526539/out/client/extension.js:9:152841)
    at p.doesFileNeedToBeFixed (/root/.vscode-remote/extensions/ms-python.python-2020.11.371526539/out/client/extension.js:39:469606)
    at /root/.vscode-remote/extensions/ms-python.python-2020.11.371526539/out/client/extension.js:39:468733
    at async Promise.all (index 0)
    at p.getFilesToBeFixed (/root/.vscode-remote/extensions/ms-python.python-2020.11.371526539/out/client/extension.js:39:468679)
    at p.updateTestSettings (/root/.vscode-remote/extensions/ms-python.python-2020.11.371526539/out/client/extension.js:39:468306) {
  code: 'FileNotFound',
  name: 'EntryNotFound (FileSystemError)'
}
Error 2020-12-02 08:59:46: Failed to check if file needs to be fixed EntryNotFound (FileSystemError): Unable to read file 'vscode-remote://vsonline+f206027f-0efb-4a62-b3ad-cdca607daff2/root/workspace/python-sample-tweeterapp/.vscode/settings.json' (EntryNotFound (FileSystemError): Error: ENOENT: no such file or directory, open '/root/workspace/python-sample-tweeterapp/.vscode/settings.json')
    at _handleError (/root/.vscode-remote/bin/bf21395291146c014220eb70b54fdfc0a15956b5/out/vs/server/remoteExtensionHostProcess.js:765:473)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)
    at y.readText (/root/.vscode-remote/extensions/ms-python.python-2020.11.371526539/out/client/extension.js:9:152841)
    at p.doesFileNeedToBeFixed (/root/.vscode-remote/extensions/ms-python.python-2020.11.371526539/out/client/extension.js:39:469606)
    at /root/.vscode-remote/extensions/ms-python.python-2020.11.371526539/out/client/extension.js:39:468733
    at async Promise.all (index 1)
    at p.getFilesToBeFixed (/root/.vscode-remote/extensions/ms-python.python-2020.11.371526539/out/client/extension.js:39:468679)
    at p.updateTestSettings (/root/.vscode-remote/extensions/ms-python.python-2020.11.371526539/out/client/extension.js:39:468306) {
  code: 'FileNotFound',
  name: 'EntryNotFound (FileSystemError)'
}
> pyenv root
> pyenv root
> pyenv root
> pyenv root
Starting Pylance language server.
Python interpreter path: /usr/local/bin/python
> conda --version
> /usr/local/bin/python ~/.vscode-remote/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import pytest"
> /usr/local/bin/python ~/.vscode-remote/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import pytest"
> conda info --json
> conda --version
> /usr/local/bin/python ~/.vscode-remote/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import pip"
> /usr/local/bin/python ~/.vscode-remote/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import pip"
> /usr/local/bin/python ~/.vscode-remote/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import pytest"
> /usr/local/bin/python ~/.vscode-remote/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py -c "import pytest"
> /usr/local/bin/python ~/.vscode-remote/extensions/ms-python.python-2020.11.371526539/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir ~/workspace/python-sample-tweeterapp -s --cache-clear tweeter
cwd: ~/workspace/python-sample-tweeterapp
> /usr/local/bin/python ~/.vscode-remote/extensions/ms-python.python-2020.11.371526539/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir ~/workspace/python-sample-tweeterapp -s --cache-clear tweeter
cwd: ~/workspace/python-sample-tweeterapp
> /usr/local/bin/python ~/.vscode-remote/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py pytest --override-ini junit_family=xunit1 --rootdir ~/workspace/python-sample-tweeterapp --junit-xml=/tmp/tmp-1438SSgpcI5MgcV.xml tweeter
cwd: ~/workspace/python-sample-tweeterapp
> /usr/local/bin/python ~/.vscode-remote/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py pytest --override-ini junit_family=xunit1 --rootdir ~/workspace/python-sample-tweeterapp --junit-xml=/tmp/tmp-1438SSgpcI5MgcV.xml tweeter
cwd: ~/workspace/python-sample-tweeterapp
> /usr/local/bin/python ~/.vscode-remote/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py pytest --override-ini junit_family=xunit1 --rootdir ~/workspace/python-sample-tweeterapp --junit-xml=/tmp/tmp-1431NjahWwWZk07.xml ./tweeter/tests.py::TestTweets::test_tweet_creation
cwd: ~/workspace/python-sample-tweeterapp
> /usr/local/bin/python ~/.vscode-remote/extensions/ms-python.python-2020.11.371526539/pythonFiles/pyvsc-run-isolated.py pytest --override-ini junit_family=xunit1 --rootdir ~/workspace/python-sample-tweeterapp --junit-xml=/tmp/tmp-1431NjahWwWZk07.xml ./tweeter/tests.py::TestTweets::test_tweet_creation
cwd: ~/workspace/python-sample-tweeterapp

Output for Python Test Log in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

python /root/.vscode-remote/extensions/ms-python.python-2020.11.371526539/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir /root/workspace/python-sample-tweeterapp -s --cache-clear tweeter
============================= test session starts ==============================
platform linux -- Python 3.9.0, pytest-6.1.2, py-1.9.0, pluggy-0.13.1
rootdir: /root/workspace/python-sample-tweeterapp, configfile: pytest.ini
collected 3 items

tweeter/tests.py ...                                                     [100%]

--------------- generated xml file: /tmp/tmp-1438SSgpcI5MgcV.xml ---------------
============================== 3 passed in 0.26s ===============================
============================= test session starts ==============================
platform linux -- Python 3.9.0, pytest-6.1.2, py-1.9.0, pluggy-0.13.1
rootdir: /root/workspace/python-sample-tweeterapp, configfile: pytest.ini
collected 1 item

tweeter/tests.py .                                                       [100%]

--------------- generated xml file: /tmp/tmp-1431NjahWwWZk07.xml ---------------
============================== 1 passed in 0.22s ===============================

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
ericsnowcurrentlycommented, Feb 8, 2021

That’s part of the fix we are working on. Up to now we were simply ignoring the results.

1reaction
luabudcommented, Feb 2, 2021

@ericsnowcurrently actually no, I’m able to reproduce it locally too!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Testing Python in Visual Studio Code
The Python extension supports testing with Python's built-in unittest ... locates those tests and provides you with various commands to run and debug...
Read more >
How to handle test failures — pytest documentation
This will invoke the Python debugger on every failure (or KeyboardInterrupt). Often you might only want to do this for the first failing...
Read more >
Python in Visual Studio Code – April 2022 Release
In this release we're introducing the following changes: Pylint extension; Interpreter display in the status bar moved to the right; Simpler way ...
Read more >
Debugging Your Unit Test Suite in Python | Capital One
If you run your tests with pytest --pdb, it will automatically drop into a debugger on every test that fails or has an...
Read more >
pytest cannot import module while python can - Stack Overflow
To fix simply remove the tests.py file and put all your tests inside the tests/ folder. For your specific case the fix will...
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