Code coverage analysis of Lib/asyncio/graph.py reveals several uncovered branches and error-handling blocks. We need to add tests for the following scenarios in test_asyncio/test_graph.py:
- Invalid Types:
- Triggering
TypeError by passing a non-Future object to capture_call_graph() and _build_graph_for_future().
- Context Errors & Fallbacks:
- Triggering
RuntimeError by calling capture_call_graph() outside of a running event loop without providing a future.
- Returning
None from capture_call_graph() (and subsequently "" from format_call_graph()) when called inside a running event loop, but not within an active task (when no future is provided).
- The
limit Parameter:
- Testing the truncation logic using both positive and negative
limit values in capture_call_graph() and _build_graph_for_future().
- Generator Introspection:
- Hitting the
elif hasattr(coro, 'ag_await') branch in _build_graph_for_future() to test ag_await traversal.
- Formatting standard (synchronous) generators in
format_call_graph() to test the except AttributeError fallback that accesses gi_frame and gi_code.
Linked PRs
Code coverage analysis of
Lib/asyncio/graph.pyreveals several uncovered branches and error-handling blocks. We need to add tests for the following scenarios intest_asyncio/test_graph.py:TypeErrorby passing a non-Futureobject tocapture_call_graph()and_build_graph_for_future().RuntimeErrorby callingcapture_call_graph()outside of a running event loop without providing afuture.Nonefromcapture_call_graph()(and subsequently""fromformat_call_graph()) when called inside a running event loop, but not within an active task (when nofutureis provided).limitParameter:limitvalues incapture_call_graph()and_build_graph_for_future().elif hasattr(coro, 'ag_await')branch in_build_graph_for_future()to testag_awaittraversal.format_call_graph()to test theexcept AttributeErrorfallback that accessesgi_frameandgi_code.Linked PRs