Text differences

When showing the explanation for short strings, pytest uses a simple difference method:

_____________________ test_default_player_class _____________________

def test_default_player_class():
x = get_default_player_class()
> assert x == 'sorcerer'
E AssertionError: assert 'warrior' == 'sorcerer'
E - warrior
E + sorcerer

Longer strings show a smarter delta, using difflib.ndiff to quickly spot the differences:

__________________ test_warrior_short_description ___________________

def test_warrior_short_description():
desc = get_short_class_description('warrior')
> assert desc == 'A battle-hardened veteran, can equip heavy armor and weapons.'
E AssertionError: assert 'A battle-har... and weapons.' == 'A battle-hard... and weapons.'
E - A battle-hardened veteran, favors heavy armor and weapons.
E ? ^ ^^^^
E + A battle-hardened veteran, can equip heavy armor and weapons.
E ? ^ ^^^^^^^

Multiline strings are also treated specially:


def test_warrior_long_description():
desc = get_long_class_description('warrior')
> assert desc == textwrap.dedent('''\
A seasoned veteran of many battles. Strength and Dexterity
allow to yield heavy armor and weapons, as well as carry
more equipment. Weak in magic.
''')
E AssertionError: assert 'A seasoned v... \n' == 'A seasoned ve... \n'
E - A seasoned veteran of many battles. High Strength and Dexterity
E ? -----
E + A seasoned veteran of many battles. Strength and Dexterity
E allow to yield heavy armor and weapons, as well as carry
E - more equipment while keeping a light roll. Weak in magic.
E ? ---------------------------
E + more equipment. Weak in magic.