summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_contextlib.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2021-06-29 08:27:04 (GMT)
committerGitHub <noreply@github.com>2021-06-29 08:27:04 (GMT)
commit20a88004bae8ead66a205a125e1fe979376fc3ea (patch)
tree6b8007ba8c981cfdb52cc0a674e0491588ab50e0 /Lib/test/test_contextlib.py
parent48e3a1d95aee013974121fcafe19816c0e9a41da (diff)
downloadcpython-20a88004bae8ead66a205a125e1fe979376fc3ea.zip
cpython-20a88004bae8ead66a205a125e1fe979376fc3ea.tar.gz
cpython-20a88004bae8ead66a205a125e1fe979376fc3ea.tar.bz2
bpo-12022: Change error type for bad objects in "with" and "async with" (GH-26809)
A TypeError is now raised instead of an AttributeError in "with" and "async with" statements for objects which do not support the context manager or asynchronous context manager protocols correspondingly.
Diffstat (limited to 'Lib/test/test_contextlib.py')
-rw-r--r--Lib/test/test_contextlib.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/test/test_contextlib.py b/Lib/test/test_contextlib.py
index 453ef6c..dbc3f5f 100644
--- a/Lib/test/test_contextlib.py
+++ b/Lib/test/test_contextlib.py
@@ -491,7 +491,7 @@ class TestContextDecorator(unittest.TestCase):
def __exit__(self, *exc):
pass
- with self.assertRaises(AttributeError):
+ with self.assertRaisesRegex(TypeError, 'the context manager'):
with mycontext():
pass
@@ -503,7 +503,7 @@ class TestContextDecorator(unittest.TestCase):
def __uxit__(self, *exc):
pass
- with self.assertRaises(AttributeError):
+ with self.assertRaisesRegex(TypeError, 'the context manager.*__exit__'):
with mycontext():
pass