https://github.com/python/cpython/commit/b66a4ad9fc32b63da2ba10db24cbc8f4e29f781a
commit: b66a4ad9fc32b63da2ba10db24cbc8f4e29f781a
branch: main
author: Thomas Grainger <[email protected]>
committer: kumaraditya303 <[email protected]>
date: 2024-12-22T18:16:02+05:30
summary:
gh-127949: fix resource warnings in `test_tasks.py` (#128172)
files:
M Lib/test/test_asyncio/test_tasks.py
diff --git a/Lib/test/test_asyncio/test_tasks.py
b/Lib/test/test_asyncio/test_tasks.py
index 5b8979a8bbd13a..7d6d0564a9a9db 100644
--- a/Lib/test/test_asyncio/test_tasks.py
+++ b/Lib/test/test_asyncio/test_tasks.py
@@ -2698,17 +2698,17 @@ def __str__(self):
initial_refcount = sys.getrefcount(obj)
coro = coroutine_function()
- loop = asyncio.new_event_loop()
- task = asyncio.Task.__new__(asyncio.Task)
+ with contextlib.closing(asyncio.EventLoop()) as loop:
+ task = asyncio.Task.__new__(asyncio.Task)
- for _ in range(5):
- with self.assertRaisesRegex(RuntimeError, 'break'):
- task.__init__(coro, loop=loop, context=obj, name=Break())
+ for _ in range(5):
+ with self.assertRaisesRegex(RuntimeError, 'break'):
+ task.__init__(coro, loop=loop, context=obj, name=Break())
- coro.close()
- del task
+ coro.close()
+ del task
- self.assertEqual(sys.getrefcount(obj), initial_refcount)
+ self.assertEqual(sys.getrefcount(obj), initial_refcount)
def add_subclass_tests(cls):
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]