Kaydet (Commit) 17ebaa93 authored tarafından Berker Peksag's avatar Berker Peksag

Issue #24857: Comparing call_args to a long sequence now correctly returns a

boolean result instead of raising an exception.

Patch by A Kaptur.
...@@ -2005,8 +2005,7 @@ class _Call(tuple): ...@@ -2005,8 +2005,7 @@ class _Call(tuple):
else: else:
other_args = () other_args = ()
other_kwargs = value other_kwargs = value
else: elif len_other == 2:
# len 2
# could be (name, args) or (name, kwargs) or (args, kwargs) # could be (name, args) or (name, kwargs) or (args, kwargs)
first, second = other first, second = other
if isinstance(first, str): if isinstance(first, str):
...@@ -2017,6 +2016,8 @@ class _Call(tuple): ...@@ -2017,6 +2016,8 @@ class _Call(tuple):
other_args, other_kwargs = (), second other_args, other_kwargs = (), second
else: else:
other_args, other_kwargs = first, second other_args, other_kwargs = first, second
else:
return False
if self_name and other_name != self_name: if self_name and other_name != self_name:
return False return False
......
...@@ -300,6 +300,9 @@ class MockTest(unittest.TestCase): ...@@ -300,6 +300,9 @@ class MockTest(unittest.TestCase):
self.assertEqual(mock.call_args, self.assertEqual(mock.call_args,
((sentinel.Arg,), {"kw": sentinel.Kwarg})) ((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): def test_assert_called_with(self):
mock = Mock() mock = Mock()
......
...@@ -98,6 +98,9 @@ Core and Builtins ...@@ -98,6 +98,9 @@ Core and Builtins
Library 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 #23144: Make sure that HTMLParser.feed() returns all the data, even - Issue #23144: Make sure that HTMLParser.feed() returns all the data, even
when convert_charrefs is True. when convert_charrefs is True.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment