pytest-dev / pytest-dev/pytest
Duplicate test nodeids in command line arguments show incorrect collection count but execute only once
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 14.5k
- Forks
- 3.4k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 35
Description
Description:
When passing duplicate test nodeids in the command line arguments, pytest shows an incorrect collection count but only executes the test once.
Steps to Reproduce:
Run pytest with duplicate test nodeids:
pytest tests/test_foo.py::test_pass tests/test_foo.py::test_pass
Observed Behavior:
collected 2 items
tests/test_foo.py::test_pass PASSED [100%]
============================== 1 passed in 0.01s ===============================
The output shows "collected 2 items" but only executes and reports 1 test
The progress percentage shows [100%] after one test
Expected Behavior:
Either:
Pytest should deduplicate the nodeids during collection and show "collected 1 item", or
Pytest should execute the test twice (if intentional duplicate execution is desired)
Environment:
pytest version: 8.3.5
Python version: 3.12
OS: macos
Additional Information:
This might cause confusion when:
Accidentally passing duplicate tests in complex command line invocations
Using tools that generate pytest command lines automatically
Trying to understand test counts in CI output
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 reproducing the command with the duplicate tests/test_foo.py::test_pass nodeid and trace how command-line nodeids are collected and reported. Done means the collection count, progress percentage, and executed test count consistently reflect the chosen duplicate-nodeid behavior, with coverage for this reproduction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100