File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change 11"""Tests for tasks.py."""
22
33import collections
4+ import contextlib
45import contextvars
56import gc
67import io
@@ -2499,17 +2500,17 @@ def __str__(self):
24992500 initial_refcount = sys .getrefcount (obj )
25002501
25012502 coro = coroutine_function ()
2502- loop = asyncio .new_event_loop ()
2503- task = asyncio .Task .__new__ (asyncio .Task )
2503+ with contextlib . closing ( asyncio .new_event_loop ()) as loop :
2504+ task = asyncio .Task .__new__ (asyncio .Task )
25042505
2505- for _ in range (5 ):
2506- with self .assertRaisesRegex (RuntimeError , 'break' ):
2507- task .__init__ (coro , loop = loop , context = obj , name = Break ())
2506+ for _ in range (5 ):
2507+ with self .assertRaisesRegex (RuntimeError , 'break' ):
2508+ task .__init__ (coro , loop = loop , context = obj , name = Break ())
25082509
2509- coro .close ()
2510- del task
2510+ coro .close ()
2511+ del task
25112512
2512- self .assertEqual (sys .getrefcount (obj ), initial_refcount )
2513+ self .assertEqual (sys .getrefcount (obj ), initial_refcount )
25132514
25142515
25152516def add_subclass_tests (cls ):
You can’t perform that action at this time.
0 commit comments