From c3166ee84a5b0529c5e1a4f4db391b0b82a65fd0 Mon Sep 17 00:00:00 2001 From: Floris Bruynooghe Date: Wed, 22 Sep 2010 18:52:07 +0100 Subject: [PATCH] Fix bug when the right list was longer then the left Thanks to Holger for finding this. --HG-- branch : trunk --- py/_plugin/pytest_assertion.py | 2 +- testing/plugin/test_pytest_assertion.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) 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