]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-131707: fix unawaited coroutine warning in test_coroutines.Corouti… (#131708)
authorThomas Grainger <tagrain@gmail.com>
Tue, 25 Mar 2025 08:29:51 +0000 (08:29 +0000)
committerGitHub <noreply@github.com>
Tue, 25 Mar 2025 08:29:51 +0000 (08:29 +0000)
gh-131707: fix unawaited coroutine warning in test_coroutines.CoroutineTest.test_17

Lib/test/test_coroutines.py

index d78eaaca2796a6ff1a9320bd3d27ba25049e024d..deeaa724e79544f1f23a27472368e1305f016705 100644 (file)
@@ -1199,8 +1199,8 @@ class CoroutineTest(unittest.TestCase):
             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: