mirror of
https://github.com/python/cpython.git
synced 2025-10-21 22:22:48 +00:00
gh-105726: Add __slots__
to AbstractContextManager
and AbstractAsyncContextManager
(#106771)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
This commit is contained in:
parent
cc25ca16ee
commit
55408f86d7
4 changed files with 29 additions and 0 deletions
|
@ -37,6 +37,18 @@ class TestAbstractAsyncContextManager(unittest.TestCase):
|
|||
async with manager as context:
|
||||
self.assertIs(manager, context)
|
||||
|
||||
@_async_test
|
||||
async def test_slots(self):
|
||||
class DefaultAsyncContextManager(AbstractAsyncContextManager):
|
||||
__slots__ = ()
|
||||
|
||||
async def __aexit__(self, *args):
|
||||
await super().__aexit__(*args)
|
||||
|
||||
with self.assertRaises(AttributeError):
|
||||
manager = DefaultAsyncContextManager()
|
||||
manager.var = 42
|
||||
|
||||
@_async_test
|
||||
async def test_async_gen_propagates_generator_exit(self):
|
||||
# A regression test for https://bugs.python.org/issue33786.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue