pytest-dev / pytest-dev/pytest

Not recognizing paths with left square bracket

Open
#10,329 14 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic: collection
Dominant language
Python
Stars
14.5k
Forks
3.4k
Avg merge
2d 9h
Merged PRs (30d)
35

Description

  • a detailed description of the bug or problem you are having
  • output of pip list from the virtual environment you are using
  • pytest and operating system versions
  • minimal example if possible
pip list
Package    Version
---------- -------
attrs      22.1.0
iniconfig  1.1.1
packaging  21.3
pip        22.2.2
pluggy     1.0.0
py         1.11.0
pyparsing  3.0.9
pytest     7.1.3
setuptools 65.4.1
tomli      2.0.1
wheel      0.37.1

pytest skips everything after a left square bracket if provided with a path to a folder

~/workspace/pytest_test via 🐍 v3.10.6 (pytest_test) 
❯ pytest
============================= test session starts ==============================
platform linux -- Python 3.10.6, pytest-7.1.3, pluggy-1.0.0
rootdir: /home/user/pytest_test
collected 2 items                                                              

simple/d1/test_public.py .                                               [ 50%]
simple[hard]/d2/test_public.py .                                         [100%]

============================== 2 passed in 0.01s ===============================
~/workspace/pytest_test via 🐍 v3.10.6 (pytest_test) 
❯ pytest simple\[hard\]/
============================= test session starts ==============================
platform linux -- Python 3.10.6, pytest-7.1.3, pluggy-1.0.0
rootdir: /home/user/pytest_test
collected 1 item                                                               

simple/d1/test_public.py .                                               [100%]

============================== 1 passed in 0.00s ===============================
~/workspace/pytest_test via 🐍 v3.10.6 (pytest_test) 
❯ pytest 'simple[hard]/'
============================= test session starts ==============================
platform linux -- Python 3.10.6, pytest-7.1.3, pluggy-1.0.0
rootdir: /home/user/pytest_test
collected 1 item                                                               

simple/d1/test_public.py .                                               [100%]

============================== 1 passed in 0.01s ===============================
~/workspace/pytest_test via 🐍 v3.10.6 (pytest_test) 
❯ pytest "simple[hard]/"
============================= test session starts ==============================
platform linux -- Python 3.10.6, pytest-7.1.3, pluggy-1.0.0
rootdir: /home/user/pytest_test
collected 1 item                                                               

simple/d1/test_public.py .                                               [100%]

============================== 1 passed in 0.01s ===============================

Check out the provided path in the second block and the path pytest tests

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the shown pytest commands and compare how the escaped and quoted simple[hard]/ paths are collected. Done means pytest recognizes the bracketed directory when passed as a path, while the existing examples continue to collect the expected tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.