Closed hoonhout closed 1 year ago
Hi @hoonhout π thank you for reporting this issue!
I tried reproducing your issue, however I don't get the same logs as what you pasted.
test_api.py
file:def test_api():
print("test api")
pass
setup.cfg
file:[tool:pytest]
addopts = --black
> /anaconda3/bin/python ~/.vscode/extensions/ms-python.python-2019.8.30787/pythonFiles/testing_tools/run_adapter.py discover pytest -- -s --cache-clear
equivalent command: /anaconda3/bin/python -m pytest --black --collect-only -s --cache-clear
ERROR: usage: run_adapter.py [options] [file_or_dir] [file_or_dir] [...]
run_adapter.py: error: unrecognized arguments: --black
inifile: /Users/kimiguel/Documents/Sandbox/conda-pytest/setup.cfg
rootdir: /Users/kimiguel/Documents/Sandbox/conda-pytest
Traceback (most recent call last):
File "/Users/kimiguel/.vscode/extensions/ms-python.python-2019.8.30787/pythonFiles/testing_tools/run_adapter.py", line 18, in <module>
main(tool, cmd, subargs, toolargs)
File "/Users/kimiguel/.vscode/extensions/ms-python.python-2019.8.30787/pythonFiles/testing_tools/adapter/__main__.py", line 90, in main
parents, result = run(toolargs, **subargs)
File "/Users/kimiguel/.vscode/extensions/ms-python.python-2019.8.30787/pythonFiles/testing_tools/adapter/pytest/_discovery.py", line 36, in discover
raise Exception('pytest discovery failed (exit code {})'.format(ec))
Exception: pytest discovery failed (exit code 4)
Could you provide me with a sample test file or repo? Additionally, I have a couple of questions:
--black
and/or --pylama
from your setup.cfg
file?path/to/conda/python -m pytest
)Thanks!
Hi @kimadeline,
Thanks for looking into the issue.
I just realised that I forgot to mention that I'm running inside a Docker container using the Visual Studio Code Remote - Containers extension. I did not test if the problem exists outside Docker, but I put a minimal (not) working example in this repo: https://github.com/hoonhout/issue-6994
If you open this repo in VSCode and reload the window in a DevContainer, tests will not be discovered unless you remove the options --black
and --pylama
from setup.cfg
.
Bas
Thank you for providing more information and a sample repo, I could reproduce your issue using it π
π A few notes:
--black
or --pylama
with version 2019.6.24221 of the Python extension either.I've got the same using --flakes
[pytest]
testpaths = tests
addopts = --flakes
[pytest]
python_paths = src
testpaths = tests
Hello! I have reviewed this issue and given the architectural changes of the testing rewrite, this issue should no longer exist on the rewrite. Therefore I am going to close this issue but please comment or open a new issue if you are still seeing a problem when you try this yourself!
To use the rewrite yourself just add βpython.experiments.optInto": ["pythonTestAdapter"]
to your user settings. You can confirm you have the rewrite enabled by setting your log level to trace, via the Developer: Set Log Level
command in the command palette. Then check to see if Experiment 'pythonTestAdapter' is active
is in your python logs.
Thanks!
Environment data
"python.jediEnabled"
set to; more info #3977): noExpected behaviour
pytest
tests are discovered by extension and displayed in theTest
panel;CodeLens
options are added to the test functions.Actual behaviour
pytest
tests are discovered by extension, but not displayed in theTest
panel; noCodeLens
options are added to the test functions.Test discovery exits with code
3
if and only if the options--black
and/or--pylama
are added to the pytest comment through thesetup.cfg
file ([tool:pytest]
->addopts
)Steps to reproduce:
test_api.py
file with atest_api
function..vscode/settings.json
:--black
and/or--pylama
tosetup.cfg
->[tool:pytest]
->addopts
.Ctrl-Shift-P
->Python: Discover tests
Logs
Truncated output for
Python Test Log
in theOutput
panel (View
βOutput
, change the drop-down the upper-right of theOutput
panel toPython Test Log
)Related
Might be related to https://github.com/microsoft/vscode-python/issues/5458#issuecomment-520019947