August 2018
Beginner
160 pages
4h 8m
English
Assertion failures for lists also show only differing items by default:
____________________ test_get_starting_equiment _____________________ def test_get_starting_equiment(): expected = ['long sword', 'shield']> assert get_starting_equipment('warrior') == expectedE AssertionError: assert ['long sword'...et', 'shield'] == ['long sword', 'shield']E At index 1 diff: 'warrior set' != 'shield'E Left contains more items, first extra item: 'shield'E Use -v to get the full difftests\test_assert_demo.py:71: AssertionError
Note that pytest shows which index differs, and also that the -v flag can be used to show the complete difference between the lists:
____________________ test_get_starting_equiment _____________________ def test_get_starting_equiment(): ...
Read now
Unlock full access