coverage-instrumentation-pattern
CommunityFix missing async coverage with sysmon
System Documentation
What problem does it solve?
Prevents misleading Python test coverage results when using pytest in Python 3.12+ with async frameworks like FastAPI and httpx, by selecting the correct coverage backend to avoid false missing lines.
Core Features & Use Cases
- Backend comparison (ctrace vs sysmon): Identifies when the default coverage backend under-measures async call stacks and switches to PEP-669 sys.monitoring.
- Fast activation via config or env: Supports enabling sysmon using the COVERAGE_CORE environment variable, .coveragerc, or pyproject.toml.
- CI gate re-calibration guidance: Recommends adjusting cov-fail-under thresholds after changing the backend so coverage checks remain meaningful.
Use case: You add or modify tests, yet gateway/admin logic still shows unexpectedly low coverage because async routes and ASGI middleware aren’t fully captured by ctrace.
Quick Start
Run pytest with the sysmon backend by setting COVERAGE_CORE to sysmon, for example for your source directory: COVERAGE_CORE=sysmon pytest --cov=src/.
Dependency Matrix
Required Modules
None requiredComponents
Standard package💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: coverage-instrumentation-pattern Download link: https://github.com/saintgo7/claude-skills/archive/main.zip#coverage-instrumentation-pattern Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.