diff --git a/py/_plugin/pytest_assertion.py b/py/_plugin/pytest_assertion.py index 226da79c7..9e6355f41 100644 --- a/py/_plugin/pytest_assertion.py +++ b/py/_plugin/pytest_assertion.py @@ -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) diff --git a/testing/plugin/test_pytest_assertion.py b/testing/plugin/test_pytest_assertion.py index 9d750896f..abada10b2 100644 --- a/testing/plugin/test_pytest_assertion.py +++ b/testing/plugin/test_pytest_assertion.py @@ -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