Fix bug when the right list was longer then the left

Thanks to Holger for finding this.

--HG--
branch : trunk
This commit is contained in:
Floris Bruynooghe 2010-09-22 18:52:07 +01:00
parent 56b955dfb5
commit c3166ee84a
2 changed files with 7 additions and 1 deletions

View File

@ -89,7 +89,7 @@ def _compare_eq_sequence(left, right):
'first extra item: %s' % left[len(right)]]
elif len(left) < len(right):
explanation += ['Right contains more items, '
'first extra item: %s' % right[len(right)]]
'first extra item: %s' % right[len(left)]]
return explanation + _pprint_diff(left, right)

View File

@ -117,6 +117,12 @@ class TestAssertCompare:
expl = plugin.pytest_assert_binrepr('==', [0, 1], [0, 2])
assert len(expl) > 1
def test_list_different_lenghts(self):
expl = plugin.pytest_assert_binrepr('==', [0, 1], [0, 1, 2])
assert len(expl) > 1
expl = plugin.pytest_assert_binrepr('==', [0, 1, 2], [0, 1])
assert len(expl) > 1
def test_dict(self):
expl = plugin.pytest_assert_binrepr('==', {'a': 0}, {'a': 1})
assert len(expl) > 1