Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrectly dropping brackets on display of assertions #925

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

Incorrectly dropping brackets on display of assertions #925

DRMacIver opened this issue Aug 7, 2015 · 3 comments
Labels
topic: reporting related to terminal output and user-facing messages and errors type: bug problem that needs to be addressed
Milestone

Comments

@DRMacIver
Copy link

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
Copy link
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)

@nicoddemus nicoddemus added type: bug problem that needs to be addressed topic: reporting related to terminal output and user-facing messages and errors labels Aug 7, 2015
@RedBeardCode
Copy link
Contributor

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

@RedBeardCode
Copy link
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.

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 added this to the 3.0 milestone Jun 26, 2016
This was referenced Nov 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: reporting related to terminal output and user-facing messages and errors type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

4 participants