pytest-dev / pytest-dev/pytest
Misleading message "Right contains one more item"
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 14.5k
- Forks
- 3.4k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 35
Description
When pytest compares lists of different length and tries to show what the extra items are, it prints incorrect message "Right contains one more item" pointing to the wrong item. At the same time the "Full diff" section correctly indicates extra item. For "Left contains" issue is the same.
Minimal example:
def test_cmp():
> assert ['1', '2', '3'] == ['1', '2', '0', '3']
E AssertionError: assert ['1', '2', '3'] == ['1', '2', '0', '3']
E
E At index 2 diff: '3' != '0'
E Right contains one more item: '3'
E
E Full diff:
E [
E '1',
E '2',
E - '0',
E '3',
E ]
versions:
Ubuntu 22.04.5 LTS
pytest 8.3.3
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 running the minimal list-comparison example from the issue with pytest and compare the summary message with the Full diff section. Trace the assertion-diff reporting path, then add a regression test showing that the extra-item message identifies the correct item for both Right contains and Left contains cases.
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