mirror of
https://github.com/python/cpython.git
synced 2025-10-04 22:20:46 +00:00
bpo-30266: support "= None" pattern in AbstractContextManager (GH-1448) (GH-2054)
contextlib.AbstractContextManager now supports anti-registration
by setting __enter__ = None or __exit__ = None, following the pattern
introduced in bpo-25958..
(cherry picked from commit 57161aac5e
)
This commit is contained in:
parent
e380c19b7e
commit
753422f6e3
3 changed files with 16 additions and 3 deletions
|
@ -44,6 +44,16 @@ class TestAbstractContextManager(unittest.TestCase):
|
|||
|
||||
self.assertTrue(issubclass(DefaultEnter, AbstractContextManager))
|
||||
|
||||
class NoEnter(ManagerFromScratch):
|
||||
__enter__ = None
|
||||
|
||||
self.assertFalse(issubclass(NoEnter, AbstractContextManager))
|
||||
|
||||
class NoExit(ManagerFromScratch):
|
||||
__exit__ = None
|
||||
|
||||
self.assertFalse(issubclass(NoExit, AbstractContextManager))
|
||||
|
||||
|
||||
class ContextManagerTestCase(unittest.TestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue