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

refactor: simplify bound method representation #12492

Conversation

farbodahm
Copy link
Contributor

@farbodahm farbodahm commented Jun 19, 2024

Closes #389

With the help of @flub and @obestwalter, we were able to find an easy way to simplify the output of assertion failures to something like this, while keeping the old behavior same as before for unbounded objects:

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

    def test():
>       assert Help().fun() == 2
E       assert 1 == 2
E        +  where 1 = fun()
E        +    where fun = <test_local.Help object at 0x1074be230>.fun
E        +      where <test_local.Help object at 0x1074be230> = Help()

test_local.py:13: AssertionError
=========================== 1 failed in 0.03 seconds ===========================

However, I opened an issue (#12499) to refactor the data structure of assertions AST (in rewerite.py) from string to something more flexible.

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Jun 20, 2024
@farbodahm farbodahm force-pushed the refactor/simplify-bound-method-representation branch 3 times, most recently from 685e457 to 7828d15 Compare June 20, 2024 12:21
@farbodahm farbodahm marked this pull request as ready for review June 20, 2024 14:26
@farbodahm farbodahm force-pushed the refactor/simplify-bound-method-representation branch 2 times, most recently from 0b912ca to f115a0f Compare June 21, 2024 14:18
@farbodahm farbodahm force-pushed the refactor/simplify-bound-method-representation branch from de3a747 to f6fef46 Compare June 21, 2024 15:55
@RonnyPfannschmidt RonnyPfannschmidt enabled auto-merge (squash) June 21, 2024 16:20
@RonnyPfannschmidt RonnyPfannschmidt merged commit 34e2829 into pytest-dev:main Jun 21, 2024
28 checks passed
@farbodahm farbodahm deleted the refactor/simplify-bound-method-representation branch June 21, 2024 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:chronographer:provided (automation) changelog entry is part of PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

enhance readability of assertion introspection on bound methods
2 participants