gh-83403: Test `parent` param in `Mock.__init__` (#103630)

This commit is contained in:
Nikita Sobolev 2023-05-30 10:36:22 +03:00 committed by GitHub
parent 5454db4ace
commit 219f01b185
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View 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()