diff options
author | Shantanu <12621235+hauntsaninja@users.noreply.github.com> | 2022-12-24 13:39:39 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-24 19:39:39 +0000 |
commit | e4b43ebb3afbd231a4e5630e7e358aa3093f8677 (patch) | |
tree | 03fa3d002c6d84b0f54bf5be9251df7e455b7ba7 /Lib/test/test_unittest/testmock/testasync.py | |
parent | 46e6a28308def2c3a71c679a6fa4ed7d520802b9 (diff) | |
download | cpython-e4b43ebb3afbd231a4e5630e7e358aa3093f8677.tar.gz cpython-e4b43ebb3afbd231a4e5630e7e358aa3093f8677.zip |
gh-100287: Fix unittest.mock.seal with AsyncMock (#100496)
Diffstat (limited to 'Lib/test/test_unittest/testmock/testasync.py')
-rw-r--r-- | Lib/test/test_unittest/testmock/testasync.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Lib/test/test_unittest/testmock/testasync.py b/Lib/test/test_unittest/testmock/testasync.py index 52a3b71be1e..471162dc505 100644 --- a/Lib/test/test_unittest/testmock/testasync.py +++ b/Lib/test/test_unittest/testmock/testasync.py @@ -11,7 +11,7 @@ support.requires_working_socket(module=True) from asyncio import run, iscoroutinefunction from unittest import IsolatedAsyncioTestCase from unittest.mock import (ANY, call, AsyncMock, patch, MagicMock, Mock, - create_autospec, sentinel, _CallList) + create_autospec, sentinel, _CallList, seal) def tearDownModule(): @@ -300,6 +300,14 @@ class AsyncSpecTest(unittest.TestCase): self.assertIsInstance(mock.async_method, AsyncMock) self.assertIsInstance(mock.normal_method, Mock) + def test_spec_normal_methods_on_class_with_mock_seal(self): + mock = Mock(AsyncClass) + seal(mock) + with self.assertRaises(AttributeError): + mock.normal_method + with self.assertRaises(AttributeError): + mock.async_method + def test_spec_async_attributes_instance(self): async_instance = AsyncClass() async_instance.async_func_attr = async_func @@ -1089,3 +1097,7 @@ class AsyncMockAssert(unittest.TestCase): 'Actual: [call(1)]'))) as cm: self.mock.assert_has_awaits([call(), call(1, 2)]) self.assertIsInstance(cm.exception.__cause__, TypeError) + + +if __name__ == '__main__': + unittest.main() |