mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
Autospec functions should propagate mock calls to parent GH-11273
This commit is contained in:
parent
f1b9abe35f
commit
9c3f284de5
3 changed files with 23 additions and 0 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue