Skip to content

"assert x in L" failures don't expand the value of L #5985

@progval

Description

@progval

Hello,

When running pytest -vv, I get this:

    def test_foo():
        x = 42
        L = list(range(40))
>       assert x in L
E       assert 42 in [0, 1, 2, 3, 4, 5, ...]

test_foo.py:4: AssertionError

I would expect it to fully expand the value of a list, like pytest does for equality comparisons when -vv is provided:

    def test_foo():
        x = 42
        L = list(range(40))
>       assert x == L
E       assert 42 == [0, 1, 2, 3, 4, 5, ...]
E         -42
E         +[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39]

test_foo.py:4: AssertionError

pytest version: 5.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: rewriterelated to the assertion rewrite mechanism

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions