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

Comments

@DRMacIver
Copy link

@DRMacIver DRMacIver commented Aug 7, 2015

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

@The-Compiler 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
Copy link
Contributor

@RedBeardCode RedBeardCode commented Jun 25, 2016

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

@RedBeardCode
Copy link
Contributor

@RedBeardCode 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 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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.