PyTest: compare long strings
However, comparing long strings would be extremely difficult for us.
Luckily pytest will point us to the first character that differs.
import string
def get_string(s):
return string.printable + s + string.printable
def test_long_strings():
assert get_string('a') == get_string('b')
$ pytest -q test_long_strings.py
Output:
def test_long_strings():
> assert get_string('a') == get_string('b')
E AssertionError: assert '0123456789ab...t\n\r\x0b\x0c' == '0123456789abc...t\n\r\x0b\x0c'
E Skipping 90 identical leading characters in diff, use -v to show
E Skipping 91 identical trailing characters in diff, use -v to show
E {|}~
E
E - a012345678
E ? ^
E + b012345678
E ? ^