mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +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
|
@ -24,6 +24,16 @@ class TestAbstractContextManager(unittest.TestCase):
|
|||
manager = DefaultEnter()
|
||||
self.assertIs(manager.__enter__(), manager)
|
||||
|
||||
def test_slots(self):
|
||||
class DefaultContextManager(AbstractContextManager):
|
||||
__slots__ = ()
|
||||
|
||||
def __exit__(self, *args):
|
||||
super().__exit__(*args)
|
||||
|
||||
with self.assertRaises(AttributeError):
|
||||
DefaultContextManager().var = 42
|
||||
|
||||
def test_exit_is_abstract(self):
|
||||
class MissingExit(AbstractContextManager):
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue