pytest-dev / pytest-dev/pytest

assertion diffs: slightly confusing full diff for `range`

Open
#6,772 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

>       assert range(5) == range(7)
E       assert range(0, 5) == range(0, 7)
E         Right contains 2 more items, first extra item: 5
E         Full diff:
E         - range(0, 7)
E         ?          ^
E         + range(0, 5)
E         ?          ^

This is what pprint.pformat returns.
It could handle range classes in a special way and call list on them maybe before.

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

Reproduce the shown range assertion first, then trace pytest's assertion-diff formatting and the pprint.pformat result for range values. Done means the full diff presents range(5) versus range(7) without confusing character-only markers, with regression coverage for this example.

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
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.