Pytest discovery stuck in Output panel
See original GitHub issueIssue Type: Bug
Behaviour
Expected vs. Actual
Running pytest
in the terminal works. Running the discovery command from VS Code directly works:
> ~/.cache/pypoetry/virtualenvs/lol-data-rest-api-m4zklELf-py3.10/bin/python ~/.vscode-server/extensions/ms-python.python-2022.2.1924087327/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir . --cache-clear --runxfail -s rest_api/tests
[{"rootid": ".", "root": "/home/tolki/development/mobalab/mobalab_backend", "parents": [{"id": "./rest_api", "kind": "folder", "name": "rest_api", "parentid": ".", "relpath": "./rest_api"}, {"id": "./rest_api/tests", "kind": "folder", "name": "tests", "parentid": "./rest_api", "relpath": "./rest_api/tests"}, {"id": "./rest_api/tests/test_games.py", "kind": "file", "name": "test_games.py", "parentid": "./rest_api/tests", "relpath": "./rest_api/tests/test_games.py"}, {"id": "./rest_api/tests/test_games.py::test_add_note", "kind": "function", "name": "test_add_note", "parentid": "./rest_api/tests/test_games.py"}, {"id": "./rest_api/tests/test_games.py::test_delete_riot_game", "kind": "function", "name": "test_delete_riot_game", "parentid": "./rest_api/tests/test_games.py"}, {"id": "./rest_api/tests/test_games.py::test_get_game_champion", "kind": "function", "name": "test_get_game_champion", "parentid": "./rest_api/tests/test_games.py"}, {"id": "./rest_api/tests/test_games.py::test_insert_and_delete_game", "kind": "function", "name": "test_insert_and_delete_game", "parentid": "./rest_api/tests/test_games.py"}, {"id": "./rest_api/tests/test_games.py::test_update_game", "kind": "function", "name": "test_update_game", "parentid": "./rest_api/tests/test_games.py"}, {"id": "./rest_api/tests/test_get_game_details.py", "kind": "file", "name": "test_get_game_details.py", "parentid": "./rest_api/tests", "relpath": "./rest_api/tests/test_get_game_details.py"}, {"id": "./rest_api/tests/test_get_game_details.py::test_get_all_kills", "kind": "function", "name": "test_get_all_kills", "parentid": "./rest_api/tests/test_get_game_details.py"}, {"id": "./rest_api/tests/test_get_game_details.py::test_get_game_building_kills", "kind": "function", "name": "test_get_game_building_kills", "parentid": "./rest_api/tests/test_get_game_details.py"}, {"id": "./rest_api/tests/test_get_game_details.py::test_get_game_epic_monsters_kills", "kind": "function", "name": "test_get_game_epic_monsters_kills", "parentid": "./rest_api/tests/test_get_game_details.py"}, {"id": "./rest_api/tests/test_get_game_details.py::test_get_game_gold", "kind": "function", "name": "test_get_game_gold", "parentid": "./rest_api/tests/test_get_game_details.py"}, {"id": "./rest_api/tests/test_get_game_details.py::test_get_game_kills", "kind": "function", "name": "test_get_game_kills", "parentid": "./rest_api/tests/test_get_game_details.py"},
(...)
But in the OUTPUT/Python
tab the process is stuck and never finds tests.
If I forcefully stop it, the logs are:
[ERROR 2022-2-8 18:31:46.477]: Cancelled discovering pytest tests:
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at a.runTestDiscovery (/home/tolki/.vscode-server/extensions/ms-python.python-2022.2.1924087327/out/client/extension.js:85:82661)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Promise.all (index 0)
at E.refreshTestData (/home/tolki/.vscode-server/extensions/ms-python.python-2022.2.1924087327/out/client/extension.js:85:94259)
at v.refreshTestDataInternal (/home/tolki/.vscode-server/extensions/ms-python.python-2022.2.1924087327/out/client/extension.js:85:85653)
at async Promise.all (index 0)
at v.resolveChildren (/home/tolki/.vscode-server/extensions/ms-python.python-2022.2.1924087327/out/client/extension.js:85:86988) {
stdout: ''
}
Interestingly, the log error looks to be 1 month in the past for some reason.
Steps to reproduce:
- Launch VS Code
- No Python tests 😦
Diagnostic data
- Python version (& distribution if applicable, e.g. Anaconda): 3.10.1
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Poetry
- Value of the
python.languageServer
setting: Default
User Settings
defaultLS: {"defaultLSType":"Pylance"}
downloadLanguageServer: true
envFile: "<placeholder>"
venvPath: "<placeholder>"
venvFolders: "<placeholder>"
condaPath: "<placeholder>"
pipenvPath: "<placeholder>"
poetryPath: "<placeholder>"
languageServer: "Pylance"
linting
• enabled: true
• cwd: "<placeholder>"
• Flake8Args: "<placeholder>"
• flake8Enabled: false
• flake8Path: "<placeholder>"
• lintOnSave: true
• banditArgs: "<placeholder>"
• banditEnabled: false
• banditPath: "<placeholder>"
• mypyArgs: "<placeholder>"
• mypyEnabled: false
• mypyPath: "<placeholder>"
• pycodestyleArgs: "<placeholder>"
• pycodestyleEnabled: false
• pycodestylePath: "<placeholder>"
• prospectorArgs: "<placeholder>"
• prospectorEnabled: false
• prospectorPath: "<placeholder>"
• pydocstyleArgs: "<placeholder>"
• pydocstyleEnabled: false
• pydocstylePath: "<placeholder>"
• pylamaArgs: "<placeholder>"
• pylamaEnabled: false
• pylamaPath: "<placeholder>"
• pylintArgs: "<placeholder>"
• pylintPath: "<placeholder>"
sortImports
• args: "<placeholder>"
• path: "<placeholder>"
formatting
• autopep8Args: "<placeholder>"
• autopep8Path: "<placeholder>"
• provider: "black"
• blackArgs: "<placeholder>"
• blackPath: "<placeholder>"
• yapfArgs: "<placeholder>"
• yapfPath: "<placeholder>"
testing
• cwd: "<placeholder>"
• debugPort: 3000
• nosetestArgs: "<placeholder>"
• nosetestsEnabled: undefined
• nosetestPath: "<placeholder>"
• promptToConfigure: true
• pytestArgs: "<placeholder>"
• pytestEnabled: true
• pytestPath: "<placeholder>"
• unittestArgs: "<placeholder>"
• unittestEnabled: false
• autoTestDiscoverOnSaveEnabled: true
terminal
• activateEnvironment: true
• executeInFileDir: "<placeholder>"
• launchArgs: "<placeholder>"
experiments
• enabled: true
• optInto: []
• optOutFrom: []
insidersChannel: "off"
tensorBoard
• logDirectory: "<placeholder>"
Extension version: 2022.2.1924087327 VS Code version: Code 1.65.0 (b5205cc8eb4fbaa726835538cd82372cc0222d43, 2022-03-02T11:12:08.962Z) OS version: Windows_NT x64 10.0.22000 Restricted Mode: No Remote OS version: Linux x64 5.10.16.3-microsoft-standard-WSL2
System Info
Item | Value |
---|---|
CPUs | AMD Ryzen 7 5800X 8-Core Processor (16 x 3793) |
GPU Status | 2d_canvas: enabled gpu_compositing: enabled multiple_raster_threads: enabled_on oop_rasterization: enabled opengl: enabled_on rasterization: enabled skia_renderer: enabled_on video_decode: enabled vulkan: disabled_off webgl: enabled webgl2: enabled |
Load (avg) | undefined |
Memory (System) | 31.90GB (12.93GB free) |
Process Argv | –crash-reporter-id 0b342376-bcbb-4c08-9c59-05e04abdb7b7 |
Screen Reader | no |
VM | 0% |
Item | Value |
---|---|
Remote | WSL: Ubuntu |
OS | Linux x64 5.10.16.3-microsoft-standard-WSL2 |
CPUs | AMD Ryzen 7 5800X 8-Core Processor (16 x 3792) |
Memory (System) | 15.58GB (8.76GB free) |
VM | 0% |
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythonvspyl392:30443607
pythontb:30283811
pythonvspyt551cf:30345471
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
vscorecescf:30445987
pythondataviewer:30285071
vscod805cf:30301675
pythonvspyt200:30340761
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
vsc1dst:30438360
pythonvs932:30410667
wslgetstarted:30449410
vsclayoutctrt:30448491
dsvsc009:30440023
pythonvspyt640:30442238
vsbas813:30436447
vscscmwlcmt:30438805
vscgsvidc:30447482
helix:30440343
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:14 (1 by maintainers)
Top Results From Across the Web
VSCode pytest test discovery fails - python - Stack Overflow
Use Python code for discovery of tests when using pytest. ... are set correctly, run tests discovery and its output (see OUTPUT window)....
Read more >Python Test Explorer for Visual Studio Code
Shows a Test Explorer in the Test view in VS Code's sidebar with all detected tests and suites and their state · Convenient...
Read more >pytest Documentation - Read the Docs
pytest discovers all tests following its Conventions for Python test discovery, so it finds both test_ prefixed functions.
Read more >Bug listing with status RESOLVED with resolution OBSOLETE ...
output by itself is sometimes not detailed enough. ... Bug:279125 - "app-editors/gvim: tests get stuck and needs to be killed" status:RESOLVED ...
Read more >Troubleshooting build errors | Cloud Build Documentation
This page provides troubleshooting strategies as well as solutions for some common error messages that you might see when running a build.
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
pytest
runs perfectly in the terminal. Runningpython -m pytest --rootdir . -s --cache-clear rest_api/tests
works.Even the test discovery command works with the python
2022.04
extension:~/.cache/pypoetry/virtualenvs/lol-data-rest-api-m4zklELf-py3.9/bin/python ~/.vscode-server/extensions/ms-python.python-2022.4.0/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir . -s --cache-clear .
That’s what’s weird, everything works from a terminal, but for some reason the extension is stuck forever. Is it trying to index files in huge folders, like
node_modules
? I have added it to mynorecursedirs
inpytest.ini
but it did not have any impact.We are working on a
pytest
adapter that does not interfere with pytests own detection. The current test adapter we have seems to be interacting with pytest in a way where it can cause errors when parsing JSON output. (Tracking item: https://github.com/microsoft/vscode-python/issues/19791 )I will add this issue to that task for verification when it is done.