From: Berker Peksag Date: Sun, 26 Feb 2017 13:06:11 +0000 (+0300) Subject: Fix unittest.mock._Call: don't ignore name (#307) X-Git-Tag: v3.5.4rc1~324 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6b585fddc9ad472d8c962aba26cf25809451b2b5;p=thirdparty%2FPython%2Fcpython.git Fix unittest.mock._Call: don't ignore name (#307) Issue #28961: Fix unittest.mock._Call helper: don't ignore the name parameter anymore. Patch written by Jiajun Huang. (cherry picked from commits 84b6fb0eea29b3b28a1a11124526b01ec0c9d17a and dea1536fd3a8424d537794cd53715df0989cbbe1) Conflicts: Misc/NEWS --- diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py index 9bc40bc2d154..99658d47a356 100644 --- a/Lib/unittest/mock.py +++ b/Lib/unittest/mock.py @@ -1945,9 +1945,8 @@ class _Call(tuple): If the _Call has no name then it will match any name. """ - def __new__(cls, value=(), name=None, parent=None, two=False, + def __new__(cls, value=(), name='', parent=None, two=False, from_kall=True): - name = '' args = () kwargs = {} _len = len(value) diff --git a/Lib/unittest/test/testmock/testhelpers.py b/Lib/unittest/test/testmock/testhelpers.py index 34776347daa6..d2202a7b4132 100644 --- a/Lib/unittest/test/testmock/testhelpers.py +++ b/Lib/unittest/test/testmock/testhelpers.py @@ -306,6 +306,11 @@ class CallTest(unittest.TestCase): other_args = _Call(((1, 2), {'a': 3})) self.assertEqual(args, other_args) + def test_call_with_name(self): + self.assertEqual(_Call((), 'foo')[0], 'foo') + self.assertEqual(_Call((('bar', 'barz'),),)[0], '') + self.assertEqual(_Call((('bar', 'barz'), {'hello': 'world'}),)[0], '') + class SpecSignatureTest(unittest.TestCase): diff --git a/Misc/NEWS b/Misc/NEWS index abd4e53ef449..bab13da4342d 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -32,6 +32,9 @@ Extension Modules Library ------- +- Issue #28961: Fix unittest.mock._Call helper: don't ignore the name parameter + anymore. Patch written by Jiajun Huang. + - bpo-29532: Altering a kwarg dictionary passed to functools.partial() no longer affects a partial object after creation.