11"""Tests for the asyncio tools script."""
22
3+ import unittest
4+
35from Lib .asyncio import tools
4- from test .test_asyncio import utils as test_utils
56
67
78# mock output of get_all_awaited_by function.
209210 # test case containing two roots
210211 (
211212 (
212- 1 ,
213+ 9 ,
213214 [
214- (2 , "Task-1" , []),
215- (3 , "timer" , [[["awaiter" ], 4 ]]),
216- (4 , "subtask1" , [[["main" ], 2 ]]),
215+ (5 , "Task-5" , []),
216+ (6 , "Task-6" , [[["main2" ], 5 ]]),
217+ (7 , "Task-7" , [[["main2" ], 5 ]]),
218+ (8 , "Task-8" , [[["main2" ], 5 ]]),
217219 ],
218220 ),
219221 (
220- 5 ,
222+ 10 ,
221223 [
222- (6 , "Task-1" , []),
223- (7 , "sleeper" , [[["awaiter2" ], 8 ]]),
224- (8 , "subtask2" , [[["main" ], 6 ]]),
224+ (1 , "Task-1" , []),
225+ (2 , "Task-2" , [[["main" ], 1 ]]),
226+ (3 , "Task-3" , [[["main" ], 1 ]]),
227+ (4 , "Task-4" , [[["main" ], 1 ]]),
225228 ],
226229 ),
230+ (11 , []),
227231 (0 , []),
228232 ),
229233 ([]),
230234 (
231235 [
232236 [
233- "└── (T) Task-1 " ,
234- " └── main " ,
235- " └ ── (T) subtask1 " ,
236- " └ ── awaiter " ,
237- " └── (T) timer " ,
237+ "└── (T) Task-5 " ,
238+ " └── main2 " ,
239+ " ├ ── (T) Task-6 " ,
240+ " ├ ── (T) Task-7 " ,
241+ " └── (T) Task-8 " ,
238242 ],
239243 [
240244 "└── (T) Task-1" ,
241245 " └── main" ,
242- " └ ── (T) subtask2 " ,
243- " └ ── awaiter2 " ,
244- " └── (T) sleeper " ,
246+ " ├ ── (T) Task-2 " ,
247+ " ├ ── (T) Task-3 " ,
248+ " └── (T) Task-4 " ,
245249 ],
246250 ]
247251 ),
248252 (
249253 [
250- [1 , "0x3" , "timer" , "awaiter" , "subtask1" , "0x4" ],
251- [1 , "0x4" , "subtask1" , "main" , "Task-1" , "0x2" ],
252- [5 , "0x7" , "sleeper" , "awaiter2" , "subtask2" , "0x8" ],
253- [5 , "0x8" , "subtask2" , "main" , "Task-1" , "0x6" ],
254+ [9 , "0x6" , "Task-6" , "main2" , "Task-5" , "0x5" ],
255+ [9 , "0x7" , "Task-7" , "main2" , "Task-5" , "0x5" ],
256+ [9 , "0x8" , "Task-8" , "main2" , "Task-5" , "0x5" ],
257+ [10 , "0x2" , "Task-2" , "main" , "Task-1" , "0x1" ],
258+ [10 , "0x3" , "Task-3" , "main" , "Task-1" , "0x1" ],
259+ [10 , "0x4" , "Task-4" , "main" , "Task-1" , "0x1" ],
254260 ]
255261 ),
256262 ],
366372]
367373
368374
369- class TestAsyncioTools (test_utils .TestCase ):
375+ class TestAsyncioTools (unittest .TestCase ):
370376
371377 def test_asyncio_utils (self ):
372378 for input_ , cycles , tree , table in TEST_INPUTS :
@@ -376,7 +382,5 @@ def test_asyncio_utils(self):
376382 except tools .CycleFoundException as e :
377383 self .assertEqual (e .cycles , cycles )
378384 else :
379- print (tools .print_async_tree (input_ ))
380385 self .assertEqual (tools .print_async_tree (input_ ), tree )
381- print (tools .build_task_table (input_ ))
382386 self .assertEqual (tools .build_task_table (input_ ), table )
0 commit comments