vscode-python: Debug of parametrized pytest fails to find test when using zsh shells

Environment data

  • VS Code version: 1.42.1
  • Extension version (available under the Extensions sidebar): 2020.2.64379
  • OS and version: Darwin x64 19.3.0
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.6.8
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): virtualenv
  • Relevant/affected Python packages and their versions:
  • pytest version 5.3.2,
  • pytest-django-3.7.0
  • Relevant/affected Python-related VS Code extensions and their versions: XXX
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info #3977): Jedi
  • Value of the python.languageServer setting: Not Set (UI says Microsoft)

Expected behaviour

When running the test without debug.

platform darwin -- Python 3.6.8, pytest-5.3.2, py-1.8.0, pluggy-0.13.0 -- /Users/abartlett/.virtualenvs/ssam/bin/python
cachedir: .pytest_cache
Django settings: ssam.settings.test_settings (from ini file)
rootdir: /Users/abartlett/src/ssam, inifile: /Users/abartlett/src/ssam/src/pytest.ini
plugins: django-3.7.0, atlassian-ldap3-test-helpers-0.0.6
collecting ... collected 1 item

src/test_demo.py::test_parametrize_debug[a] PASSED                       [100%]

========================= 1 passed, 1 warning in 0.01s =========================

from output tab:

> ~/.virtualenvs/ssam/bin/python -m pytest --rootdir ~/src/ssam --junitxml=/var/folders/ly/c_bdp3bd36x4y5lvckk_4hym0000gp/T/tmp-40404hMBR4wrPGYY.xml -c ~/src/ssam/src/pytest.ini -vv ./src/test_demo.py::test_parametrize_debug[a]
cwd: ~/src/ssam

Actual behaviour

zsh: no matches found: ./src/test_demo.py::test_parametrize_debug[a]

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

Using the following code, I select to debug one of the parametrized options. Doing run all appears to work.

import pytest


@pytest.mark.parametrize("ab", ["a", "b"])
def test_parametrize_debug(ab):
    assert ab != "c"

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

User belongs to experiment group 'ShowPlayIcon - start'
User belongs to experiment group 'DebugAdapterFactory - experiment'
User belongs to experiment group 'PtvsdWheels37 - experiment'
User belongs to experiment group 'UseTerminalToGetActivatedEnvVars - control'
User belongs to experiment group 'WebHostNotebook - control'
...
Starting Jedi Python language engine.
...

> ~/.virtualenvs/ssam/bin/python ~/.vscode/extensions/ms-python.python-2020.2.64397/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir ~/src/ssam -s --cache-clear -c ~/src/ssam/src/pytest.ini -vv
cwd: ~/src/ssam
> ~/.virtualenvs/ssam/bin/python -m pytest --rootdir ~/src/ssam --junitxml=/var/folders/ly/c_bdp3bd36x4y5lvckk_4hym0000gp/T/tmp-40404GqogbegWaYl.xml -c ~/src/ssam/src/pytest.ini -vv ./src/test_demo.py::test_parametrize_debug[a] ./src/test_demo.py::test_parametrize_debug[b]
cwd: ~/src/ssam

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging)

Warn Python Extension: 2020-03-03 10:21:05: Unknown command line option passed into args parser for tests '-vv'. Please report on https://github.com/Microsoft/vscode-python/issues/new

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 2
  • Comments: 16 (1 by maintainers)

Most upvoted comments

I use zsh and have the same problem. zfanelle answer (removing "console": "integratedTerminal" from launch.json) works great.

Okay, here is what I have found. It looks like a problem affecting zsh. I don’t have a clean zsh env to test with right now.

If I remove "console": "integratedTerminal", from the launch.json debug entry, it works.

If I use bash for my shell "terminal.integrated.shell.osx": "/bin/bash", it works

My install of zsh, via brew zsh 5.5.1 (x86_64-apple-darwin18.0.0) is what I use daily.

Using the zsh that is distributed with mac os zsh 5.7.1 (x86_64-apple-darwin19.0) still has the issue. I can still escape the square brackets and it works.

Oh, word wrap doesnt happen so it’s not obvious. At the end of the debug command, where it is defining which test to run, it tries to run it like this:

<full command> ./test_demo.py::test_parametrize_debug[a] 

As an experiment, I tried running it straight away like this, with the square brackets escaped:

 <full command> ./test_demo.py::test_parametrize_debug\[a\] 

Which worked.

Okay, here is what I have found. It looks like a problem affecting zsh. I don’t have a clean zsh env to test with right now.

If I remove "console": "integratedTerminal", from the launch.json debug entry, it works.

If I use bash for my shell "terminal.integrated.shell.osx": "/bin/bash", it works

My install of zsh, via brew zsh 5.5.1 (x86_64-apple-darwin18.0.0) is what I use daily.

Using the zsh that is distributed with mac os zsh 5.7.1 (x86_64-apple-darwin19.0) still has the issue. I can still escape the square brackets and it works.

@ashleybartlett I can confirm this bug on my own development environment as well. I have the same settings.