From 219f01b18574469f493a3d3cb91d96c2f057218c Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Tue, 30 May 2023 10:36:22 +0300 Subject: gh-83403: Test `parent` param in `Mock.__init__` (#103630) --- Lib/test/test_unittest/testmock/testmock.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Lib/test/test_unittest/testmock/testmock.py b/Lib/test/test_unittest/testmock/testmock.py index c7895e7..bb09913 100644 --- a/Lib/test/test_unittest/testmock/testmock.py +++ b/Lib/test/test_unittest/testmock/testmock.py @@ -245,6 +245,14 @@ class MockTest(unittest.TestCase): with mock.patch('builtins.open', mock.mock_open()): mock.mock_open() # should still be valid with open() mocked + def test_explicit_parent(self): + parent = Mock() + mock1 = Mock(parent=parent, return_value=None) + mock1(1, 2, 3) + mock2 = Mock(parent=parent, return_value=None) + mock2(4, 5, 6) + + self.assertEqual(parent.mock_calls, [call(1, 2, 3), call(4, 5, 6)]) def test_reset_mock(self): parent = Mock() -- cgit v0.12