Skip to content

Commit cd992bb

Browse files
committed
Merge 3.6
2 parents b27df6f + 84b6fb0 commit cd992bb

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

Lib/unittest/mock.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,9 +1951,8 @@ class _Call(tuple):
19511951
19521952
If the _Call has no name then it will match any name.
19531953
"""
1954-
def __new__(cls, value=(), name=None, parent=None, two=False,
1954+
def __new__(cls, value=(), name='', parent=None, two=False,
19551955
from_kall=True):
1956-
name = ''
19571956
args = ()
19581957
kwargs = {}
19591958
_len = len(value)

Lib/unittest/test/testmock/testhelpers.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,20 @@ def test_two_args_call(self):
306306
other_args = _Call(((1, 2), {'a': 3}))
307307
self.assertEqual(args, other_args)
308308

309+
def test_call_with_name(self):
310+
self.assertEqual(
311+
'foo',
312+
_Call((), 'foo')[0],
313+
)
314+
self.assertEqual(
315+
'',
316+
_Call((('bar', 'barz'), ), )[0]
317+
)
318+
self.assertEqual(
319+
'',
320+
_Call((('bar', 'barz'), {'hello': 'world'}), )[0]
321+
)
322+
309323

310324
class SpecSignatureTest(unittest.TestCase):
311325

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ Core and Builtins
210210
Library
211211
-------
212212

213+
- Issue #28961: Fix unittest.mock._Call helper: don't ignore the name parameter
214+
anymore. Patch written by Jiajun Huang.
215+
213216
- Issue #15812: inspect.getframeinfo() now correctly shows the first line of
214217
a context. Patch by Sam Breese.
215218

0 commit comments

Comments
 (0)