-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Refactor pytest discovery code in extension #3911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I can confirm I am also seeing the behaviour after the pytest 4.1.0 upgrade. It worked with pytest 4.0.1 |
Previous versions would contain quotes around file names:
New version of PyTest doesn't. |
I can confirm that downgrading pytest to |
The solution is fairly simple:
import pytest
class MyPlugin(object):
def pytest_collection_modifyitems(sessino, config, items):
print(items, "items from collected list")
def pytest_collection_finish(self, session):
print(list(session.items), "items from session")
pytest.main(["-v", "tests", "--collect-only"], plugins=[MyPlugin()])
|
@DonJayamanne Is this a local solution or the approach to solve the issue on vscode-python's side? |
@drorata we plan to solve it in the extension. Basically pytest does not guarantee stdout format stability so we have to change on our end. |
I don't know if this can help in all cases, but using the $ pytest --collect-only -q
tests/test_vscode.py::test_error1
tests/test_vscode.py::test_error2
tests/test_vscode.py::test_error4 |
|
I have fixed a similar issue in test explorer extension for Python. I have used the approach similar to the one used for unittest discovery https://github.com/DonJayamanne/pythonVSCode/blob/master/src/client/unittests/unittest/services/parserService.ts. To discover tests I used Hope this might be of help! |
For microsoft#3911 - Handles stdout produced by pytest in the 4.0 and 4.1 series
No longer a P1 as we have a fix for existing users |
@ericsnowcurrently can this issue be considered as done? if not, what's left here? |
Yeah, the pytest adapter solves this. |
Environment data
Local setting is:
Expected behaviour
When running
Python: Discover Unit Tests
I expect not to receive an error message.Actual behaviour
When I run
pytest
at the root of my project (from the terminal) everything works as expected: all tests are found and executed. However, when I try to runPython: Discover Unit Tests
, I get the following errorNo tests discovered, please check the configuration settings for the tests.
. The output is odd:Moreover, when I do
Python: Run All Tests
I get the above output, followed by actually running the tests and passing them (as if I was runningpytest
directly in the console).Steps to reproduce:
tmp
) and installpytest
using pipfoo.py
andtest_foo.py
(see below).pytest
in the console and see the two tests pass.Python: Discover Unit Tests
.Python: Run All Unit Tests
.Logs
Output for
Python
in theOutput
: see above.The output of running the tests is:
Output from
Console
under theDeveloper Tools
panel: I couldn't find relevant information here.The text was updated successfully, but these errors were encountered: