diff options
author | Xtreak <tir.karthi@gmail.com> | 2019-04-22 02:30:23 (GMT) |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2019-04-22 02:30:23 (GMT) |
commit | 9b21856b0fcda949de239edc7aa6cf3f2f4f77a3 (patch) | |
tree | 67b8f216a06b29748f5e573d5ab855b3462752e7 /Lib/unittest/test/testmock/testmock.py | |
parent | 9541bd321a94f13dc41163a5d7a1a847816fac84 (diff) | |
download | cpython-9b21856b0fcda949de239edc7aa6cf3f2f4f77a3.zip cpython-9b21856b0fcda949de239edc7aa6cf3f2f4f77a3.tar.gz cpython-9b21856b0fcda949de239edc7aa6cf3f2f4f77a3.tar.bz2 |
bpo-23078: Add support for {class,static}method to mock.create_autospec() (GH-11613)
Co-authored-by: Felipe <felipe.nospam.ochoa@gmail.com>
Diffstat (limited to 'Lib/unittest/test/testmock/testmock.py')
-rw-r--r-- | Lib/unittest/test/testmock/testmock.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/unittest/test/testmock/testmock.py b/Lib/unittest/test/testmock/testmock.py index 37f14c3..bdaebbe 100644 --- a/Lib/unittest/test/testmock/testmock.py +++ b/Lib/unittest/test/testmock/testmock.py @@ -1419,6 +1419,23 @@ class MockTest(unittest.TestCase): m = mock.create_autospec(object(), name='sweet_func') self.assertIn('sweet_func', repr(m)) + #Issue23078 + def test_create_autospec_classmethod_and_staticmethod(self): + class TestClass: + @classmethod + def class_method(cls): + pass + + @staticmethod + def static_method(): + pass + for method in ('class_method', 'static_method'): + with self.subTest(method=method): + mock_method = mock.create_autospec(getattr(TestClass, method)) + mock_method() + mock_method.assert_called_once_with() + self.assertRaises(TypeError, mock_method, 'extra_arg') + #Issue21238 def test_mock_unsafe(self): m = Mock() |