aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_unittest/testmock/testmock.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_unittest/testmock/testmock.py')
-rw-r--r--Lib/test/test_unittest/testmock/testmock.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_unittest/testmock/testmock.py b/Lib/test/test_unittest/testmock/testmock.py
index b81b3049d56..77f6f1eb4b7 100644
--- a/Lib/test/test_unittest/testmock/testmock.py
+++ b/Lib/test/test_unittest/testmock/testmock.py
@@ -115,6 +115,19 @@ class MockTest(unittest.TestCase):
with self.assertRaises(TypeError):
mock()
+ def test_create_autospec_should_be_configurable_by_kwargs(self):
+ """If kwargs are given to configure mock, the function must configure
+ the parent mock during initialization."""
+ mocked_result = 'mocked value'
+ class_mock = create_autospec(spec=Something, **{
+ 'return_value.meth.side_effect': [ValueError, DEFAULT],
+ 'return_value.meth.return_value': mocked_result})
+ with self.assertRaises(ValueError):
+ class_mock().meth(a=None, b=None, c=None)
+ self.assertEqual(class_mock().meth(a=None, b=None, c=None), mocked_result)
+ # Only the parent mock should be configurable because the user will
+ # pass kwargs with respect to the parent mock.
+ self.assertEqual(class_mock().return_value.meth.side_effect, None)
def test_repr(self):
mock = Mock(name='foo')