pytest-dev / pytest-dev/pytest

asserrtrepr compare - use text diff for multiline reprs

Open
#8,346 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

What's the problem this feature will solve?

when showing the diff for a multiline repr, all the lines are show as added/removes

Describe the solution you'd like

when repr is multiline use diff on it

Alternative Solutions

i'm locally delegating assertrepr_compare to use repr


from myapp import HostWrapper

def pytest_assertrepr_compare(config,  op, left, right):
    if isinstance(left, HostWrapper) and isinstance(right, HostWrapper) and op == "==":
        res = config.hook.pytest_assertrepr_compare(config=config, op=op, left=repr(left), right=repr(right))
        return res[0]

environment

still the case on pytest 6.2.0

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

Start by tracing pytest_assertrepr_compare and the comparison-reporting path for multiline repr values. Reproduce the behavior described in the issue on pytest 6.2.0 or the current code, then identify the existing text-diff behavior used for string comparisons. Done means multiline reprs produce a line-oriented diff instead of showing every line as added or removed.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.