|
11 | 11 | from asyncio import run, iscoroutinefunction |
12 | 12 | from unittest import IsolatedAsyncioTestCase |
13 | 13 | from unittest.mock import (ANY, call, AsyncMock, patch, MagicMock, Mock, |
14 | | - create_autospec, sentinel, _CallList) |
| 14 | + create_autospec, sentinel, _CallList, seal) |
15 | 15 |
|
16 | 16 |
|
17 | 17 | def tearDownModule(): |
@@ -300,6 +300,14 @@ def test_spec_normal_methods_on_class_with_mock(self): |
300 | 300 | self.assertIsInstance(mock.async_method, AsyncMock) |
301 | 301 | self.assertIsInstance(mock.normal_method, Mock) |
302 | 302 |
|
| 303 | + def test_spec_normal_methods_on_class_with_mock_seal(self): |
| 304 | + mock = Mock(AsyncClass) |
| 305 | + seal(mock) |
| 306 | + with self.assertRaises(AttributeError): |
| 307 | + mock.normal_method |
| 308 | + with self.assertRaises(AttributeError): |
| 309 | + mock.async_method |
| 310 | + |
303 | 311 | def test_spec_async_attributes_instance(self): |
304 | 312 | async_instance = AsyncClass() |
305 | 313 | async_instance.async_func_attr = async_func |
@@ -1089,3 +1097,7 @@ async def f(x=None): pass |
1089 | 1097 | 'Actual: [call(1)]'))) as cm: |
1090 | 1098 | self.mock.assert_has_awaits([call(), call(1, 2)]) |
1091 | 1099 | self.assertIsInstance(cm.exception.__cause__, TypeError) |
| 1100 | + |
| 1101 | + |
| 1102 | +if __name__ == '__main__': |
| 1103 | + unittest.main() |
0 commit comments