summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2015-09-09 23:35:25 +0300
committerRobert Collins <rbtcollins@hp.com>2016-03-23 18:36:07 +1300
commitf40c660f75f6a25b6ff78dc4b71086cf17805f5d (patch)
tree29a1fe12288811ec6e092e6988fe47e7bac7e4ab
parent5efb4e504a6f4378dd65b825dd572d8e175ebd2e (diff)
downloadmock-f40c660f75f6a25b6ff78dc4b71086cf17805f5d.tar.gz
Issue #24857: Comparing call_args to a long sequence now correctly returns a
boolean result instead of raising an exception. Patch by A Kaptur.
-rw-r--r--NEWS3
-rw-r--r--mock/mock.py5
-rw-r--r--mock/tests/testmock.py3
3 files changed, 9 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 9c0ff3c..5e91ac8 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,9 @@
Library
-------
+- Issue #24857: Comparing call_args to a long sequence now correctly returns a
+ boolean result instead of raising an exception. Patch by A Kaptur.
+
- Issue #23004: mock_open() now reads binary data correctly when the type of
read_data is bytes. Initial patch by Aaron Hill.
diff --git a/mock/mock.py b/mock/mock.py
index 358537d..4846a46 100644
--- a/mock/mock.py
+++ b/mock/mock.py
@@ -2169,8 +2169,7 @@ class _Call(tuple):
else:
other_args = ()
other_kwargs = value
- else:
- # len 2
+ elif len_other == 2:
# could be (name, args) or (name, kwargs) or (args, kwargs)
first, second = other
if isinstance(first, basestring):
@@ -2181,6 +2180,8 @@ class _Call(tuple):
other_args, other_kwargs = (), second
else:
other_args, other_kwargs = first, second
+ else:
+ return False
if self_name and other_name != self_name:
return False
diff --git a/mock/tests/testmock.py b/mock/tests/testmock.py
index d60f579..8ec9a60 100644
--- a/mock/tests/testmock.py
+++ b/mock/tests/testmock.py
@@ -326,6 +326,9 @@ class MockTest(unittest.TestCase):
self.assertEqual(mock.call_args,
((sentinel.Arg,), {"kw": sentinel.Kwarg}))
+ # Comparing call_args to a long sequence should not raise
+ # an exception. See issue 24857.
+ self.assertFalse(mock.call_args == "a long sequence")
def test_assert_called_with(self):
mock = Mock()