summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_contextlib_async.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-10-10 09:12:28 (GMT)
committerGitHub <noreply@github.com>2023-10-10 09:12:28 (GMT)
commit2fc80814bf55445fb2cc56b25ec54d8e308e3408 (patch)
tree20fd204c6a10e7c811bf4f27661c9dadea42dcf2 /Lib/test/test_contextlib_async.py
parent36886726a2fe9a2c8511cfb405704f39cf184d7c (diff)
downloadcpython-2fc80814bf55445fb2cc56b25ec54d8e308e3408.zip
cpython-2fc80814bf55445fb2cc56b25ec54d8e308e3408.tar.gz
cpython-2fc80814bf55445fb2cc56b25ec54d8e308e3408.tar.bz2
[3.12] gh-110378: Close invalid generators in contextmanager and asynccontextmanager (GH-110499) (#110588)
contextmanager and asynccontextmanager context managers now close an invalid underlying generator object that yields more then one value. (cherry picked from commit 96fed66a65097eac2dc528ce29c9ba676bb07689) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Lib/test/test_contextlib_async.py')
-rw-r--r--Lib/test/test_contextlib_async.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/test/test_contextlib_async.py b/Lib/test/test_contextlib_async.py
index 3d43ed0..e519dff 100644
--- a/Lib/test/test_contextlib_async.py
+++ b/Lib/test/test_contextlib_async.py
@@ -204,6 +204,9 @@ class AsyncContextManagerTestCase(unittest.TestCase):
await ctx.__aenter__()
with self.assertRaises(RuntimeError):
await ctx.__aexit__(TypeError, TypeError('foo'), None)
+ if support.check_impl_detail(cpython=True):
+ # The "gen" attribute is an implementation detail.
+ self.assertFalse(ctx.gen.ag_suspended)
@_async_test
async def test_contextmanager_trap_no_yield(self):
@@ -225,6 +228,9 @@ class AsyncContextManagerTestCase(unittest.TestCase):
await ctx.__aenter__()
with self.assertRaises(RuntimeError):
await ctx.__aexit__(None, None, None)
+ if support.check_impl_detail(cpython=True):
+ # The "gen" attribute is an implementation detail.
+ self.assertFalse(ctx.gen.ag_suspended)
@_async_test
async def test_contextmanager_non_normalised(self):