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

enhance readability of assertion introspection on bound methods #389

Closed
pytestbot opened this issue Nov 19, 2013 · 3 comments · Fixed by #12492
Closed

enhance readability of assertion introspection on bound methods #389

pytestbot opened this issue Nov 19, 2013 · 3 comments · Fixed by #12492
Assignees
Labels
status: help wanted developers would like help from experts on this topic topic: tracebacks related to displaying and handling of tracebacks type: enhancement new feature or API change, should be merged into features branch

Comments

@pytestbot
Copy link
Contributor

Originally reported by: Ronny Pfannschmidt (BitBucket: RonnyPfannschmidt, GitHub: RonnyPfannschmidt)


given

#!python

class Help:
    def fun(self):
        return 1

def test():
    assert Help().fun() == 2

result

#!text

=================================== FAILURES ===================================
_____________________________________ test _____________________________________

    def test():
>       assert Help().fun() == 2
E       assert 1 == 2
E        +  where 1 = <bound method Help.fun of <example.Help instance at 0x256a830>>()
E        +    where <bound method Help.fun of <example.Help instance at 0x256a830>> = <example.Help instance at 0x256a830>.fun
E        +      where <example.Help instance at 0x256a830> = Help()

example.py:7: AssertionError
=========================== 1 failed in 0.03 seconds ===========================

desired:

#!text

=================================== FAILURES ===================================
_____________________________________ test _____________________________________

    def test():
>       assert Help().fun() == 2
E       assert 1 == 2
E        +  where 1 = Help().fun()

example.py:7: AssertionError
=========================== 1 failed in 0.03 seconds ===========================

more complex examples need a discussion


@pytestbot pytestbot added the type: enhancement new feature or API change, should be merged into features branch label Jun 15, 2015
@pfctdayelise pfctdayelise added the topic: tracebacks related to displaying and handling of tracebacks label Jul 25, 2015
@bmannix
Copy link

bmannix commented Aug 12, 2015

I'd like to see this feature as well

@RonnyPfannschmidt RonnyPfannschmidt added the status: help wanted developers would like help from experts on this topic label Apr 20, 2016
fkohlgrueber pushed a commit to fkohlgrueber/pytest that referenced this issue Oct 27, 2018
@jonathangjertsen
Copy link

This would help a lot with readability in many cases. I tried to see if I could do something about this, and it seems like the fix would be somewhere in src/_pytest/assertion/util.py since that's where the exception message is generated and where all the special cases for various types are. I guess in this case we want to swap the repr for something else, but I couldn't any existing examples where that is done. Any pointers?

@RonnyPfannschmidt
Copy link
Member

i started to work on this a little while ago, but got stalled as its required to change the structure of assertion rewriting
i have no good pointer at the moment cause i havent investigate a structure of the rewrite which enables this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: help wanted developers would like help from experts on this topic topic: tracebacks related to displaying and handling of tracebacks type: enhancement new feature or API change, should be merged into features branch
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

7 participants