mirror of https://github.com/python/cpython
Fix unittest.mock._Call: don't ignore name
Issue #28961: Fix unittest.mock._Call helper: don't ignore the name parameter anymore. Patch written by Jiajun Huang.
This commit is contained in:
parent
9505b03bb0
commit
84b6fb0eea
|
@ -1961,9 +1961,8 @@ class _Call(tuple):
|
||||||
|
|
||||||
If the _Call has no name then it will match any name.
|
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):
|
from_kall=True):
|
||||||
name = ''
|
|
||||||
args = ()
|
args = ()
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
_len = len(value)
|
_len = len(value)
|
||||||
|
|
|
@ -306,6 +306,20 @@ class CallTest(unittest.TestCase):
|
||||||
other_args = _Call(((1, 2), {'a': 3}))
|
other_args = _Call(((1, 2), {'a': 3}))
|
||||||
self.assertEqual(args, other_args)
|
self.assertEqual(args, other_args)
|
||||||
|
|
||||||
|
def test_call_with_name(self):
|
||||||
|
self.assertEqual(
|
||||||
|
'foo',
|
||||||
|
_Call((), 'foo')[0],
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
'',
|
||||||
|
_Call((('bar', 'barz'), ), )[0]
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
'',
|
||||||
|
_Call((('bar', 'barz'), {'hello': 'world'}), )[0]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class SpecSignatureTest(unittest.TestCase):
|
class SpecSignatureTest(unittest.TestCase):
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #28961: Fix unittest.mock._Call helper: don't ignore the name parameter
|
||||||
|
anymore. Patch written by Jiajun Huang.
|
||||||
|
|
||||||
- Issue #15812: inspect.getframeinfo() now correctly shows the first line of
|
- Issue #15812: inspect.getframeinfo() now correctly shows the first line of
|
||||||
a context. Patch by Sam Breese.
|
a context. Patch by Sam Breese.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue