vscode-python: Python.testing.pytestArgs does not work with option -m

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:

  1. Set -m in the settings.json
{
"python.testing.pytestArgs": ["-m", "lazy"]
}
  1. 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.languageServer setting: Jedi
Output for Python in the Output panel (ViewOutput, 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

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Comments: 16 (7 by maintainers)

Most upvoted comments

apologies I got mixed up, this is waiting on https://github.com/microsoft/vscode-python/issues/21845 and that proposal will fix the incorrect arg parsing. Sorry and thank you for your patience!

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