summaryrefslogtreecommitdiff
path: root/Lib/unittest
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-01-06 18:15:51 +0100
committerVictor Stinner <victor.stinner@gmail.com>2017-01-06 18:15:51 +0100
commit4b5a4553c7513a3de9891cf3634fcc1dcd8f1175 (patch)
tree08d7c7234a189f461962226cabe322bc6d33b458 /Lib/unittest
parent3a2730f9bd5713020e5e3b1d60a71b048728af0a (diff)
downloadcpython-4b5a4553c7513a3de9891cf3634fcc1dcd8f1175.tar.gz
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.
Diffstat (limited to 'Lib/unittest')
-rw-r--r--Lib/unittest/mock.py3
-rw-r--r--Lib/unittest/test/testmock/testhelpers.py14
2 files changed, 15 insertions, 2 deletions
diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py
index f134919888..dcac5a2925 100644
--- a/Lib/unittest/mock.py
+++ b/Lib/unittest/mock.py
@@ -1961,9 +1961,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 34776347da..d5f9e7c1d6 100644
--- a/Lib/unittest/test/testmock/testhelpers.py
+++ b/Lib/unittest/test/testmock/testhelpers.py
@@ -306,6 +306,20 @@ class CallTest(unittest.TestCase):
other_args = _Call(((1, 2), {'a': 3}))
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):