changeset: 97834:df91c1879e56 branch: 3.5 parent: 97831:321d06b265cf parent: 97833:83ea55a1204a user: Berker Peksag date: Wed Sep 09 23:39:45 2015 +0300 files: Lib/unittest/mock.py Lib/unittest/test/testmock/testmock.py Misc/NEWS description: Issue #24857: Comparing call_args to a long sequence now correctly returns a boolean result instead of raising an exception. Patch by A Kaptur. diff -r 321d06b265cf -r df91c1879e56 Lib/unittest/mock.py --- a/Lib/unittest/mock.py Wed Sep 09 13:49:29 2015 -0400 +++ b/Lib/unittest/mock.py Wed Sep 09 23:39:45 2015 +0300 @@ -2005,8 +2005,7 @@ 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, str): @@ -2017,6 +2016,8 @@ 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 -r 321d06b265cf -r df91c1879e56 Lib/unittest/test/testmock/testmock.py --- a/Lib/unittest/test/testmock/testmock.py Wed Sep 09 13:49:29 2015 -0400 +++ b/Lib/unittest/test/testmock/testmock.py Wed Sep 09 23:39:45 2015 +0300 @@ -300,6 +300,9 @@ 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() diff -r 321d06b265cf -r df91c1879e56 Misc/NEWS --- a/Misc/NEWS Wed Sep 09 13:49:29 2015 -0400 +++ b/Misc/NEWS Wed Sep 09 23:39:45 2015 +0300 @@ -14,6 +14,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 #23144: Make sure that HTMLParser.feed() returns all the data, even when convert_charrefs is True.