Incorrectly dropping brackets on display of assertions #925

Closed
DRMacIver opened this Issue Aug 7, 2015 · 3 comments

Comments

Projects
None yet
4 participants
@DRMacIver

If I have the following test:

def test_ternary_display():
    assert (False == False) == False

then this will correctly fail, but will display as:

    def test_ternary_display():
>       assert (False == False) == False
E       assert False == False == False

display.py:2: AssertionError

This is wrong. The brackets are required because "False == False == False" evaluates to True. In Python this is the same as "(False == False) and (False == False)" due to the rules about chaining operators.

@The-Compiler

This comment has been minimized.

Show comment
Hide comment
@The-Compiler

The-Compiler Aug 7, 2015

Member

While looking at this in IRC, I also found a case where it's not wrong, but pytest adds/changes brackets:

>       assert (False == False) and False
E       assert (False == False and False)
Member

The-Compiler commented Aug 7, 2015

While looking at this in IRC, I also found a case where it's not wrong, but pytest adds/changes brackets:

>       assert (False == False) and False
E       assert (False == False and False)
@RedBeardCode

This comment has been minimized.

Show comment
Hide comment
@RedBeardCode

RedBeardCode Jun 25, 2016

Contributor

What would be a suspected output for the case.
assert False==(False == False)==True
?

Contributor

RedBeardCode commented Jun 25, 2016

What would be a suspected output for the case.
assert False==(False == False)==True
?

@RedBeardCode

This comment has been minimized.

Show comment
Hide comment
@RedBeardCode

RedBeardCode Jun 25, 2016

Contributor

I started to implement a solution and it works for the first given case, but to make it really general it is more work.

Contributor

RedBeardCode commented Jun 25, 2016

I started to implement a solution and it works for the first given case, but to make it really general it is more work.

RedBeardCode added a commit to RedBeardCode/pytest that referenced this issue Jun 25, 2016

RedBeardCode added a commit to RedBeardCode/pytest that referenced this issue Jun 25, 2016

@nicoddemus nicoddemus closed this in #1669 Jun 26, 2016

@nicoddemus nicoddemus added this to the 3.0 milestone Jun 26, 2016

This was referenced Aug 19, 2016

@dependencies dependencies bot referenced this issue in tjamet/caduc Nov 4, 2017

Open

pytest versions available: 3.0.0 #3

This was referenced Nov 11, 2017

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