File tree 1 file changed +9
-8
lines changed
1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change 1
1
"""Tests for tasks.py."""
2
2
3
3
import collections
4
+ import contextlib
4
5
import contextvars
5
6
import gc
6
7
import io
@@ -2499,17 +2500,17 @@ def __str__(self):
2499
2500
initial_refcount = sys .getrefcount (obj )
2500
2501
2501
2502
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 )
2504
2505
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 ())
2508
2509
2509
- coro .close ()
2510
- del task
2510
+ coro .close ()
2511
+ del task
2511
2512
2512
- self .assertEqual (sys .getrefcount (obj ), initial_refcount )
2513
+ self .assertEqual (sys .getrefcount (obj ), initial_refcount )
2513
2514
2514
2515
2515
2516
def add_subclass_tests (cls ):
You can’t perform that action at this time.
0 commit comments