On 2023-02-24 16:12:10 +1300, dn via Python-list wrote:
> In some ways, providing this information seems appropriate. Curiously, this
> does not even occur during an assert exception - despite the
> value/relationship being the whole point of using the command!
> 
>     x = 1
>     assert x == 2
> 
> AssertionError (and that's it)

Pytest is great there. If an assertion in a test case fails it analyzes
the expression to give you various levels of details:

======================================== test session starts 
========================================
platform linux -- Python 3.10.6, pytest-6.2.5, py-1.10.0, pluggy-0.13.0
rootdir: /home/hjp/tmp/t
plugins: cov-3.0.0, anyio-3.6.1
collected 1 item

test_a.py F                                                                     
              [100%]

============================================= FAILURES 
==============================================
______________________________________________ test_a 
_______________________________________________

    def test_a():
        a = [1, 2, 3]
        b = {"a": a, "b": 2}

>       assert len(a) == len(b)
E       AssertionError: assert 3 == 2
E        +  where 3 = len([1, 2, 3])
E        +  and   2 = len({'a': [1, 2, 3], 'b': 2})

test_a.py:7: AssertionError
====================================== short test summary info 
======================================
FAILED test_a.py::test_a - AssertionError: assert 3 == 2
========================================= 1 failed in 0.09s 
=========================================

        hp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | h...@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Attachment: signature.asc
Description: PGP signature

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to