Skip to content

Commit 219f01b

Browse files
authored
gh-83403: Test parent param in Mock.__init__ (#103630)
1 parent 5454db4 commit 219f01b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Lib/test/test_unittest/testmock/testmock.py

+8
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,14 @@ class B(object):
245245
with mock.patch('builtins.open', mock.mock_open()):
246246
mock.mock_open() # should still be valid with open() mocked
247247

248+
def test_explicit_parent(self):
249+
parent = Mock()
250+
mock1 = Mock(parent=parent, return_value=None)
251+
mock1(1, 2, 3)
252+
mock2 = Mock(parent=parent, return_value=None)
253+
mock2(4, 5, 6)
254+
255+
self.assertEqual(parent.mock_calls, [call(1, 2, 3), call(4, 5, 6)])
248256

249257
def test_reset_mock(self):
250258
parent = Mock()

0 commit comments

Comments
 (0)