Autospec functions should propagate mock calls to parent GH-11273

This commit is contained in:
Xtreak 2019-02-26 03:16:34 +05:30 committed by Chris Withers
parent f1b9abe35f
commit 9c3f284de5
3 changed files with 23 additions and 0 deletions

View file

@ -1830,5 +1830,18 @@ class MockTest(unittest.TestCase):
self.assertEqual(type(call.parent().parent), _Call)
def test_parent_propagation_with_create_autospec(self):
def foo(a, b):
pass
mock = Mock()
mock.child = create_autospec(foo)
mock.child(1, 2)
self.assertRaises(TypeError, mock.child, 1)
self.assertEqual(mock.mock_calls, [call.child(1, 2)])
if __name__ == '__main__':
unittest.main()