(task)
| 302 | |
| 303 | |
| 304 | def format_task(task) -> str: |
| 305 | try: |
| 306 | name = task.get_name() if hasattr(task, "get_name") else "<unknown name>" |
| 307 | coro = task.get_coro() |
| 308 | coro_name = getattr(coro, "__qualname__", None) or type(coro).__name__ |
| 309 | frame = getattr(coro, "cr_frame", None) |
| 310 | if frame: |
| 311 | location = f"{frame.f_code.co_filename}:{frame.f_lineno}" |
| 312 | else: |
| 313 | location = "no frame available" |
| 314 | return ( |
| 315 | f"Task Name : {name}\n" |
| 316 | f"Coroutine : {coro_name}\n" |
| 317 | f"Location : {location}\n" |
| 318 | f"State : {'pending' if not task.done() else 'done'}" |
| 319 | ) |
| 320 | except Exception: |
| 321 | return repr(task) |
| 322 | |
| 323 | |
| 324 | @pytest.fixture(autouse=True) |
no test coverage detected