Pytest discovery fails if something is printed to stderr
See original GitHub issueCan I get any help with pytest discovery failure?
> /usr/local/bin/python ~/.vscode-server/extensions/ms-python.python-2022.0.1786462952/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir . -s --cache-clear
cwd: .
[ERROR 2022-1-3 23:36:9.283]: Error discovering pytest tests:
[r [Error]: Graceful shutdown completed in 0.000 seconds.
at ChildProcess.<anonymous> (/root/.vscode-server/extensions/ms-python.python-2022.0.1786462952/out/client/extension.js:32:39235)
at Object.onceWrapper (events.js:422:26)
at ChildProcess.emit (events.js:315:20)
at maybeClose (internal/child_process.js:1048:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)]
Tried many different options with “python.testing.cwd” and “python.testing.pytestArgs” but without luck.
I used unit tests in the past and they work fine in VS Code.
Also I use VS Code with “Remote Container” and work inside the Docker container and run tests inside it.
Hope that you can solve this issue soon, because with pytest it doesn’t work for me. And I have no clear vision why. Thanks.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:7
- Comments:30
Top Results From Across the Web
Can pytest throw stderr on failure? - python
So basically I want pytest to throw anything in stderr when it's done if any test has failed. A solution I've found is...
Read more >How to capture stdout/stderr output
During test execution any output sent to stdout and stderr is captured. If a test or a setup method fails its according captured...
Read more >doctest — Test interactive Python examples
If you run example.py directly from the command line, doctest works its magic: ... are printed to stdout, and the final line of...
Read more >Python Unit Testing - LSST DM Developer Guide
The pytest scheme for discovering tests inside Python modules is much more flexible ... If a test command fails, that output is renamed...
Read more >Testing Python in Visual Studio Code
Unit tests are concerned only with the unit's interface—its arguments and ... If discovery fails (for example, the test framework isn't installed or...
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
Getting a similar error, however it seems like it’s because the environment location is messed up
I’m getting a very similar issue - pytest discovery not working in vscode while pytest from cmd line works fine. From the code Python output I see:
Not sure if something in conda is able to interpret
~\.vscode\extens...
as%userprofile%\.vscode\extens...
(I’m running on Windows where “~” doesn’t resolve to anything).If I try to copy that command (and replace the “~” with userprofile path), it fails as follows
(I’ve added -v flags to conda run to try to get more info):
I also tried removing the
get_output_via_markers.py
component of the command - still no success. But I noticed that it seemed to be trying to execute pytest from the conda base environment rather than the current conda env.This is the line I’m referring to - although not sure if this is a anything to do with the problem - it should be f:\anaconda\envs\msticpy\python.exe
The result is the same with or without the
-v
flags.