Skip to content

Introduce a legend for - and + in diff outputs #14743

Description

@The-Compiler

I think the main takeaway here is that, with + and -, no matter what we do, some people will find it confusing. 😅

Personally, the mental model from #6673 works well for me:

"-" means that sth. expected is missing in the result and "+" means that there are unexpected extras in the result.

Using L and R instead would kind of break that mental model for me, and make it harder to understand which one of L / R is "actual", and which is "expected".

Inspired from #3721 (comment), maybe a nice middle ground would be a small "legend" in the output? Perhaps something like:

    def test_hello_2():
>       assert some_function() == generate_expected_output()
E       assert [1, 2, 3, 40, 5, 6] == [1, 2, 3, 4, 5, 6, 7]
E         
E         At index 3 diff: 40 != 4
E         Right contains one more item: 7
E         
E         Full diff: (-: missing in left side, +: extra in left side)
E           [
E               1,
E               2,
E               3,
E         -     4,
E         +     40,
E         ?      +
E               5,
E               6,
E         -     7,
E           ]

or if we can make it work, even:

    def test_hello_2():
>       assert some_function() == generate_expected_output()
E       assert [1, 2, 3, 40, 5, 6] == [1, 2, 3, 4, 5, 6, 7]
E         
E         At index 3 diff: 40 != 4
E         Right contains one more item: 7
E         
E         Full diff:
E           -: missing in `some_function()`
E           +: extra in `some_function()`
E
E           [
E               1,
E               2,
E               3,
E         -     4,
E         +     40,
E         ?      +
E               5,
E               6,
E         -     7,
E           ]

Originally posted by @The-Compiler in #14674 (comment)


⚠️ Note, we are working on this on the pytest sprint, we don't want AI slop PRs

Metadata

Metadata

Assignees

Labels

topic: reportingrelated to terminal output and user-facing messages and errors

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions