Skip to content

Avoid unhelpful full diff for unequal range comparisons - #15154

Open
SemTiOne wants to merge 2 commits into
pytest-dev:mainfrom
SemTiOne:fix-6772-range-diff
Open

SemTiOne wants to merge 2 commits into
pytest-dev:mainfrom
SemTiOne:fix-6772-range-diff

Conversation

@SemTiOne

@SemTiOne SemTiOne commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

When comparing unequal range objects, pytest can show a full diff of their range(...) representations. This adds noise without making the mismatch any clearer.

This change skips that diff while preserving the useful sequence comparison output: the first differing index, or an extra-item summary when one range extends the other.

The shared-prefix check examines at most two items. A range's start and step determine its values, so that's enough to compare the prefix without walking through huge ranges.

Closes #6772.

  • Allow maintainers to push and squash when merging my commits. Please uncheck this if you prefer to squash the commits yourself.

Co-authored-by: OpenAI GPT-6 Luna <noreply@openai.com>
@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Oct 9, 2026
@SemTiOne
SemTiOne marked this pull request as ready for review October 9, 2026 15:56

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

assertion diffs: slightly confusing full diff for range

1 participant