From b6b0460c1217b17d1528a3d9ead508d8be6071ed Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith" Date: Thu, 6 Oct 2016 14:31:23 -0700 Subject: Fixes issue28380: unittest.mock Mock autospec functions now properly support assert_called, assert_not_called, and assert_called_once. --- Lib/unittest/mock.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Lib/unittest/mock.py') diff --git a/Lib/unittest/mock.py b/Lib/unittest/mock.py index eaa9c3d585..f134919888 100644 --- a/Lib/unittest/mock.py +++ b/Lib/unittest/mock.py @@ -193,6 +193,12 @@ def _setup_func(funcopy, mock): def assert_called_with(*args, **kwargs): return mock.assert_called_with(*args, **kwargs) + def assert_called(*args, **kwargs): + return mock.assert_called(*args, **kwargs) + def assert_not_called(*args, **kwargs): + return mock.assert_not_called(*args, **kwargs) + def assert_called_once(*args, **kwargs): + return mock.assert_called_once(*args, **kwargs) def assert_called_once_with(*args, **kwargs): return mock.assert_called_once_with(*args, **kwargs) def assert_has_calls(*args, **kwargs): @@ -223,6 +229,9 @@ def _setup_func(funcopy, mock): funcopy.assert_has_calls = assert_has_calls funcopy.assert_any_call = assert_any_call funcopy.reset_mock = reset_mock + funcopy.assert_called = assert_called + funcopy.assert_not_called = assert_not_called + funcopy.assert_called_once = assert_called_once mock._mock_delegate = funcopy -- cgit v1.2.1 From 4b5a4553c7513a3de9891cf3634fcc1dcd8f1175 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 6 Jan 2017 18:15:51 +0100 Subject: 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. --- Lib/unittest/mock.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Lib/unittest/mock.py') 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) -- cgit v1.2.1