pytest-dev / pytest

The pytest framework makes it easy to write small tests, yet scales to support complex functional testing
https://pytest.org
MIT License
11.94k stars 2.66k forks source link

refactor: simplify bound method representation #12492

Closed farbodahm closed 3 months ago

farbodahm commented 3 months ago

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.