Debug of parametrized pytest fails to find test when using zsh shells
See original GitHub issueEnvironment 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 (View
→Output
, 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
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:15
Top Results From Across the Web
How to handle test failures — pytest documentation
This will invoke the Python debugger on every failure (or KeyboardInterrupt). Often you might only want to do this for the first failing...
Read more >Debugging Failing Tests with pytest | seanh.cc - Sean Hammond
This post briefly covers some tools for debugging failing tests when using pytest.
Read more >Command-line usage — Nox 2022.11.21 documentation
You can also use pytest-style keywords using -k or --keywords , and tags using -t or ... Then running nox --session tests will...
Read more >Targets and BUILD files
Most goals require metadata about your code. For example, to run a test, you need to know about all the transitive dependencies of...
Read more >vscode-jest - Visual Studio Marketplace
Show fails inline of the expect function, as well as in the problem inspector. View and update snapshots interactively. Help debug jest tests...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub 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 worksMy 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.