diff options
| author | Jelle Zijlstra <jelle.zijlstra@gmail.com> | 2017-06-09 15:21:47 (GMT) |
|---|---|---|
| committer | Guido van Rossum <guido@python.org> | 2017-06-09 15:21:47 (GMT) |
| commit | 57161aac5eb9bcb0b43e551a1937ff0a84c1ec52 (patch) | |
| tree | 04296787a6bbf099a38d2b24ac91fc0c83a8e7df /Lib/test | |
| parent | 3b5cf85edc188345668f987c824a2acb338a7816 (diff) | |
| download | cpython-57161aac5eb9bcb0b43e551a1937ff0a84c1ec52.zip cpython-57161aac5eb9bcb0b43e551a1937ff0a84c1ec52.tar.gz cpython-57161aac5eb9bcb0b43e551a1937ff0a84c1ec52.tar.bz2 | |
bpo-30266: support "= None" pattern in AbstractContextManager (#1448)
contextlib.AbstractContextManager now supports anti-registration
by setting __enter__ = None or __exit__ = None, following the pattern
introduced in bpo-25958.
Diffstat (limited to 'Lib/test')
| -rw-r--r-- | Lib/test/test_contextlib.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_contextlib.py b/Lib/test/test_contextlib.py index b1a467d..2301f75 100644 --- a/Lib/test/test_contextlib.py +++ b/Lib/test/test_contextlib.py @@ -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): |
