(s)
| 11 | def capture_test_stack(*, fut=None, depth=1): |
| 12 | |
| 13 | def walk(s): |
| 14 | ret = [ |
| 15 | (f"T<{n}>" if '-' not in (n := s.future.get_name()) else 'T<anon>') |
| 16 | if isinstance(s.future, asyncio.Task) else 'F' |
| 17 | ] |
| 18 | |
| 19 | ret.append( |
| 20 | [ |
| 21 | ( |
| 22 | f"s {entry.frame.f_code.co_name}" |
| 23 | if entry.frame.f_generator is None else |
| 24 | ( |
| 25 | f"a {entry.frame.f_generator.cr_code.co_name}" |
| 26 | if hasattr(entry.frame.f_generator, 'cr_code') else |
| 27 | f"ag {entry.frame.f_generator.ag_code.co_name}" |
| 28 | ) |
| 29 | ) for entry in s.call_stack |
| 30 | ] |
| 31 | ) |
| 32 | |
| 33 | ret.append( |
| 34 | sorted([ |
| 35 | walk(ab) for ab in s.awaited_by |
| 36 | ], key=lambda entry: entry[0]) |
| 37 | ) |
| 38 | |
| 39 | return ret |
| 40 | |
| 41 | buf = io.StringIO() |
| 42 | asyncio.print_call_graph(fut, file=buf, depth=depth+1) |
no test coverage detected
searching dependent graphs…