mirror of https://github.com/python/cpython.git
gh-127949: fix resource warnings in `test_tasks.py` (#128172)
This commit is contained in:
parent
228f275737
commit
b66a4ad9fc
|
@ -2698,17 +2698,17 @@ def __str__(self):
|
||||||
initial_refcount = sys.getrefcount(obj)
|
initial_refcount = sys.getrefcount(obj)
|
||||||
|
|
||||||
coro = coroutine_function()
|
coro = coroutine_function()
|
||||||
loop = asyncio.new_event_loop()
|
with contextlib.closing(asyncio.EventLoop()) as loop:
|
||||||
task = asyncio.Task.__new__(asyncio.Task)
|
task = asyncio.Task.__new__(asyncio.Task)
|
||||||
|
|
||||||
for _ in range(5):
|
for _ in range(5):
|
||||||
with self.assertRaisesRegex(RuntimeError, 'break'):
|
with self.assertRaisesRegex(RuntimeError, 'break'):
|
||||||
task.__init__(coro, loop=loop, context=obj, name=Break())
|
task.__init__(coro, loop=loop, context=obj, name=Break())
|
||||||
|
|
||||||
coro.close()
|
coro.close()
|
||||||
del task
|
del task
|
||||||
|
|
||||||
self.assertEqual(sys.getrefcount(obj), initial_refcount)
|
self.assertEqual(sys.getrefcount(obj), initial_refcount)
|
||||||
|
|
||||||
|
|
||||||
def add_subclass_tests(cls):
|
def add_subclass_tests(cls):
|
||||||
|
|
Loading…
Reference in New Issue