From f7c9a32c3894932b099fcb767dd49ad1c5202c6a Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Tue, 25 Mar 2025 07:55:58 +0000 Subject: [PATCH] gh-131707: fix unawaited coroutine warning in test_coroutines.CoroutineTest.test_17 --- Lib/test/test_coroutines.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_coroutines.py b/Lib/test/test_coroutines.py index d78eaaca2796a6..deeaa724e79544 100644 --- a/Lib/test/test_coroutines.py +++ b/Lib/test/test_coroutines.py @@ -1199,8 +1199,8 @@ async def __anext__(self): def __aiter__(self): return self - anext_awaitable = anext(A(), "a").__await__() - self.assertRaises(TypeError, anext_awaitable.close, 1) + with contextlib.closing(anext(A(), "a").__await__()) as anext_awaitable: + self.assertRaises(TypeError, anext_awaitable.close, 1) def test_with_1(self): class Manager: