Skip to content

Misleading message "Right contains one more item" #13652

@sanyassh

Description

@sanyassh

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions