diff options
author | Xtreak <tir.karthi@gmail.com> | 2019-02-25 21:46:34 (GMT) |
---|---|---|
committer | Chris Withers <chris@withers.org> | 2019-02-25 21:46:34 (GMT) |
commit | 9c3f284de598550be6687964c23fd7599e53b20e (patch) | |
tree | a873c7a0f55f9a1d2c3fdf00476e7bd24563e1cd /Lib/unittest/test/testmock/testmock.py | |
parent | f1b9abe35f75393351b3d954a392122a3f8f6951 (diff) | |
download | cpython-9c3f284de598550be6687964c23fd7599e53b20e.zip cpython-9c3f284de598550be6687964c23fd7599e53b20e.tar.gz cpython-9c3f284de598550be6687964c23fd7599e53b20e.tar.bz2 |
Autospec functions should propagate mock calls to parent GH-11273
Diffstat (limited to 'Lib/unittest/test/testmock/testmock.py')
-rw-r--r-- | Lib/unittest/test/testmock/testmock.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/unittest/test/testmock/testmock.py b/Lib/unittest/test/testmock/testmock.py index 04ab522..2ad90ea 100644 --- a/Lib/unittest/test/testmock/testmock.py +++ b/Lib/unittest/test/testmock/testmock.py @@ -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() |