See this:
Note:
You can simply use the
assertstatement for asserting test
expectations. pytest’s Advanced assertion introspection will
intelligently report intermediate values of the assert expression
freeing you from the need to learn the many names of JUnit legacy
methods.
And this:
Special comparisons are done for a number of cases:
- comparing long strings: a context diff is shown
- comparing long sequences: first failing indices
- comparing dicts: different entries
And the reporting demo:
failure_demo.py:59: AssertionError
_______ TestSpecialisedExplanations.test_eq_list ________
self = <failure_demo.TestSpecialisedExplanations object at 0xdeadbeef>
def test_eq_list(self):
> assert [0, 1, 2] == [0, 1, 3]
E assert [0, 1, 2] == [0, 1, 3]
E At index 2 diff: 2 != 3
E Use -v to get the full diff
See the assertion for lists equality with literal == over there? pytest has done the hard work for you.