]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-83403: Test `parent` param in `Mock.__init__` (#103630)
authorNikita Sobolev <mail@sobolevn.me>
Tue, 30 May 2023 07:36:22 +0000 (10:36 +0300)
committerGitHub <noreply@github.com>
Tue, 30 May 2023 07:36:22 +0000 (08:36 +0100)
Lib/test/test_unittest/testmock/testmock.py

index c7895e73ad9a8c259743bda9410e14ab0c7d2dc6..bb09913d70b7cab1dce2f471dd78ffeca5fa73e7 100644 (file)
@@ -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()