Repository navigation
Python.testing.pytestArgs does not work with option -m #21798
Description
Type: Bug
Behaviour
Expected vs. Actual
For settings.json
{
"python.testing.pytestArgs": ["-m", "lazy"]
}Expect to see vscode to run pytest with argument in TEST RESULT UI
Running test with arguments: --rootdir /home/vdc/git/six --override-ini junit_family=xunit1 --junit-xml=/tmp/tmp-1147287WvATg175YF9w.xml -m lazy
But, -m is gone
Running test with arguments: --rootdir /home/vdc/git/six --override-ini junit_family=xunit1 --junit-xml=/tmp/tmp-1147287NQVjhdMkoSyI.xml
However, if you do something like that, it will work
{
"python.testing.pytestArgs": ["-m lazy"]
}Steps to reproduce:
- Set -m in the settings.json
{
"python.testing.pytestArgs": ["-m", "lazy"]
}- Run the vscode test
Personally, I clone a open source project six to replicate this issue. HOpefully, this can be replicated with any python project
Diagnostic data
- Python version (& distribution if applicable, e.g. Anaconda): 3.8.10
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Venv
- Value of the
python.languageServersetting: Jedi
Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)
2023-08-10 13:28:40.743 [info] Discover tests for workspace name: six - uri: /home/vdc/git/six
2023-08-10 13:28:40.765 [info] > ./venv/bin/python ~/.vscode-server/extensions/ms-python.python-2023.14.0/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir . -s --cache-clear
2023-08-10 13:28:40.765 [info] cwd: .
2023-08-10 13:28:45.858 [info] Discover tests for workspace name: six - uri: /home/vdc/git/six
2023-08-10 13:28:45.858 [warning] Unknown command line option passed into args parser for tests '-m lazy'. Please report on https://github.com/Microsoft/vscode-python/issues/new
2023-08-10 13:28:45.858 [warning] Unknown command line option passed into args parser for tests '-m lazy'. Please report on https://github.com/Microsoft/vscode-python/issues/new
2023-08-10 13:28:45.884 [info] > ./venv/bin/python ~/.vscode-server/extensions/ms-python.python-2023.14.0/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir . -s --cache-clear "-m lazy"
2023-08-10 13:28:45.884 [info] cwd: .
User Settings
languageServer: "Jedi"
linting
• pycodestyleEnabled: true
• pydocstyleEnabled: true
formatting
• provider: "black"
• blackArgs: "<placeholder>"
testing
• promptToConfigure: false
• pytestArgs: "<placeholder>"
• pytestEnabled: true
• autoTestDiscoverOnSaveEnabled: false
Extension version: 2023.14.0
VS Code version: Code 1.81.0 (6445d93c81ebe42c4cbd7a60712e0b17d9463e97, 2023-08-02T12:37:13.485Z)
OS version: Windows_NT x64 10.0.19044
Modes:
Remote OS version: Linux x64 5.4.0-148-generic
Remote OS version: Linux x64 5.4.0-148-generic
Remote OS version: Linux x64 5.4.0-148-generic
Activity
eleanorjboyd commentedon Aug 11, 2023
Hello! Could you try this on the rewrite, we have a new testing architecture. To try it yourself, you need to add this setting to your users
settings.json"python.experiments.optInto": ["pythonTestAdapter"].You can confirm you have the rewrite enabled by setting
"python.analysis.logLevel": "Trace",in your user settings then check forExperiment 'pythonTestAdapter'is active in your python logs.Let me know if the rewrite fixes your issue. Thanks!
mondwan commentedon Aug 21, 2023
Hi, I tried with following
{ "python.testing.pytestEnabled": true, "python.testing.pytestArgs": ["-m", "lazy"], "python.experiments.optInto": ["pythonTestAdapter"], "python.analysis.logLevel": "Trace" }But, it sounds like the experiment option cannot be active, and the option does not work as expected neither
eleanorjboyd commentedon Aug 21, 2023
hm interesting. Did you reload your vscode windows? Also, you set it in your user settings json not your workspace one correct?
mondwan commentedon Aug 22, 2023
As I am using a remote vscode, I have tried to edit my host's settings.json.
Then, I tried to reload the vscode. But, the results are the same, which is does not work as expected.
mondwan commentedon Aug 24, 2023
Here is how I reproduce this bug in a public repository
Clone a public repository https://github.com/benjaminp/six
Setup the settings.json as described
Run the tests as described
Hope this helps
eleanorjboyd commentedon Aug 29, 2023
related to #21845. We will need to overhaul args now that we have more flexibility with our architecture. This issue will be resolved by that. Thanks
eleanorjboyd commentedon Dec 6, 2023
Hi! Have you had any luck with this issue recently? We just expanded the experiment to include everyone so you should be on the rewrite (without the need for the setting). From your logs they always included
2023-08-21 11:22:28.476 [info] > ./venv/bin/python ~/.vscode-server/extensions/ms-python.python-2023.14.0/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir . -s --cache-clearwhich is the path to the old version of the code. Let me know if there are any changes, the overhaul to the args will also fix the problem but in the meantime it might help. Thanksmondwan commentedon Dec 7, 2023
Is it released? I just tried. It still does not work
I am using
ms-python.python 2023.20.0eleanorjboyd commentedon Dec 7, 2023
Are you still seeing
./venv/bin/python ~/.vscode-server/extensions/ms-python.python-2023.14.0/pythonFiles/testing_tools/run_adapter.pyin your ags? It should be enabled now unless you have a specific setting disabling all experiments.mondwan commentedon Dec 7, 2023
github-actions commentedon Jan 7, 2024
Hey Eleanor Boyd (@eleanorjboyd), this issue might need further attention.
Mond WAN (@mondwan), you can help us out by closing this issue if the problem no longer exists, or adding more information.
robertdj commentedon Jan 17, 2024
Any news on this issue?
I have noticed that I cannot debug tests if I use
["-m lazy"], but I can if I use["-m", "lazy"].eleanorjboyd commentedon Jan 17, 2024
All args must be in separate strings in the array so ["-m", "lazy"] is correct, if that is working then this is the desired behavior. Mond WAN (@mondwan), are you seeing this too? If so this issue is resolved and I will close, thanks
robertdj commentedon Jan 18, 2024
Oops! That was lacking some context.
If I use
["-m", "lazy"](or in my case["-m", "not lazy"]) then the mark filtering is NOT respected, but I CAN debug.If I use
["-m lazy"]then the mark filtering IS respected, but I CANNOT debug.mondwan commentedon Jan 18, 2024
hi Robert Dahl Jacobsen (@robertdj)
Then, there are 2 bugs.
mine one is the 1st situation. In other words, the mark filtering does not work as expected.As suggested by Eleanor Boyd (@eleanorjboyd) ,
["-m", "lazy"]should be the expected usage. But, mark filtering in this context does not work as expectedhi Eleanor Boyd (@eleanorjboyd)
I have double checked just now. It still does not work as expected. Can you show your settings & results?
eleanorjboyd commentedon Jan 25, 2024
apologies I got mixed up, this is waiting on #21845 and that proposal will fix the incorrect arg parsing. Sorry and thank you for your patience!
eleanorjboyd commentedon Dec 10, 2024
We removed arg parsing for pytest so this should no longer be an issue. I gave it a try and it seems to be resolved, please comment if you are still having an issue and I can re-open. Thanks!