pytest-dev / pytest-dev/pytest
-k expression ignores directory paths
Nobody has claimed this yet.
- 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
The -k expression does not work with directory paths. For example, pytest -k '/common' does not collect any tests from the /common folder.
- output of
pip listfrom the virtual environment you are using
Package Version
---------- -------
attrs 25.4.0
iniconfig 2.3.0
packaging 26.0
pip 25.3
pluggy 1.6.0
py 1.11.0
Pygments 2.19.2
pytest 9.0.2
setuptools 80.9.0
tomli 2.4.0
wheel 0.45.1
- pytest and operating system versions
MacOS 26.2 (25C56)
pytest 9.0.2
- minimal example if possible
Files tree:
└── tests
├── common
│ └── test_common.py
├── desktop
│ └── test_desktop.py
└── mobile
└── mobile_test.py
# test_common.py:
def test_case_common():
pass
# test_desktop.py:
def test_case_1():
pass
# test_mobile.py:
def test_case_2():
pass
Outputs:
/check-pytest [5]> pytest -k '/common'
============================= test session starts =============================
platform darwin -- Python 3.12.4, pytest-9.0.2, pluggy-1.6.0
rootdir: /check-pytest
collected 3 items / 3 deselected / 0 selected
============================= 3 deselected in 0.01s =============================
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing pytest's -k expression handling and how directory paths are represented during test collection. Reproduce the issue with the provided tests/common, tests/desktop, and tests/mobile layout using pytest -k '/common'. Done means the common directory's test is selected while unrelated tests remain deselected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100