changeset: 106020:50424a903593 branch: 3.6 parent: 106013:b14a1e81c34a user: Victor Stinner date: Fri Jan 06 18:15:51 2017 +0100 files: Lib/unittest/mock.py Lib/unittest/test/testmock/testhelpers.py Misc/NEWS description: 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. diff -r b14a1e81c34a -r 50424a903593 Lib/unittest/mock.py --- a/Lib/unittest/mock.py Fri Jan 06 10:44:44 2017 +0100 +++ b/Lib/unittest/mock.py Fri Jan 06 18:15:51 2017 +0100 @@ -1961,9 +1961,8 @@ 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 -r b14a1e81c34a -r 50424a903593 Lib/unittest/test/testmock/testhelpers.py --- a/Lib/unittest/test/testmock/testhelpers.py Fri Jan 06 10:44:44 2017 +0100 +++ b/Lib/unittest/test/testmock/testhelpers.py Fri Jan 06 18:15:51 2017 +0100 @@ -306,6 +306,20 @@ 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): diff -r b14a1e81c34a -r 50424a903593 Misc/NEWS --- a/Misc/NEWS Fri Jan 06 10:44:44 2017 +0100 +++ b/Misc/NEWS Fri Jan 06 18:15:51 2017 +0100 @@ -42,6 +42,9 @@ 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 a context. Patch by Sam Breese.