summaryrefslogtreecommitdiff
path: root/Lib/test/test_coroutines.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2021-06-29 11:27:04 +0300
committerGitHub <noreply@github.com>2021-06-29 11:27:04 +0300
commit20a88004bae8ead66a205a125e1fe979376fc3ea (patch)
tree6b8007ba8c981cfdb52cc0a674e0491588ab50e0 /Lib/test/test_coroutines.py
parent48e3a1d95aee013974121fcafe19816c0e9a41da (diff)
downloadcpython-git-20a88004bae8ead66a205a125e1fe979376fc3ea.tar.gz
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_coroutines.py')
-rw-r--r--Lib/test/test_coroutines.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/test/test_coroutines.py b/Lib/test/test_coroutines.py
index a6a199e323..9b83244b50 100644
--- a/Lib/test/test_coroutines.py
+++ b/Lib/test/test_coroutines.py
@@ -1212,7 +1212,7 @@ class CoroutineTest(unittest.TestCase):
async with CM():
body_executed = True
- with self.assertRaisesRegex(AttributeError, '__aexit__'):
+ with self.assertRaisesRegex(TypeError, 'asynchronous context manager.*__aexit__'):
run_async(foo())
self.assertIs(body_executed, False)
@@ -1228,7 +1228,7 @@ class CoroutineTest(unittest.TestCase):
async with CM():
body_executed = True
- with self.assertRaisesRegex(AttributeError, '__aenter__'):
+ with self.assertRaisesRegex(TypeError, 'asynchronous context manager'):
run_async(foo())
self.assertIs(body_executed, False)
@@ -1243,7 +1243,7 @@ class CoroutineTest(unittest.TestCase):
async with CM():
body_executed = True
- with self.assertRaisesRegex(AttributeError, '__aenter__'):
+ with self.assertRaisesRegex(TypeError, 'asynchronous context manager'):
run_async(foo())
self.assertIs(body_executed, False)