coverage-wasm
A coverage.py addon for Python line and branch coverage
from Wasm and the host in one pytest report.
Documentation · Runnable examples
Measure Python running in Pyodide, Workerd, or CPython on WASI while you
run pytest.
coverage.py measures code inside the guest.
The plugin brings its coverage data back to pytest-cov, which combines it with
host coverage in a standard coverage.py report.
Contents
Quick start
Install from PyPI
For a published stable release, use uv in your test project.
uv add --dev coverage-wasm
With pip, run python -m pip install coverage-wasm in your test environment.
Installing the package also installs coverage.py for coverage
measurement and pytest-cov for pytest integration. The distribution is
coverage-wasm on PyPI and imported as coverage_wasm.
Install from GitHub
Install from main for the latest development version.
uv add --dev git+https://github.com/alex-au-922/coveragepy-wasm.git --branch main
Run uv lock --upgrade-package coverage-wasm to update a locked main install.
For a fixed version, pick an existing Git tag and pass it to --tag.
uv add --dev git+https://github.com/alex-au-922/coveragepy-wasm.git --tag v0.2.0-rc.1
Install from a local checkout with uv add --dev /path/to/coverage-wasm.
Run with coverage
Choose a runtime below, then run pytest with your usual coverage options.
uv run pytest --cov --cov-report=html
pytest loads the plugin automatically. The run shows Wasm coverage enabled
and reports how many tests contributed guest data. Open htmlcov/index.html
to see the merged report. Add -v to see which tests contributed.
Runtimes
| Runtime | pytest integration |
|---|---|
| Pyodide | selenium_standalone from pytest-pyodide |
| Workerd | targets.wrangler(bundle) with a prebuilt Python Worker |
| CPython on WASI | targets.wasi(argv, grants=grants) for a script and filesystem grants |
The runnable examples include fixtures and show what to expect in the HTML reports.
Coverage configuration
Use coverage.py's [paths] to map guest filenames back to your source tree.
Set branch = true to measure branch coverage. See the
coverage configuration guide for an example and
the report options.
Compatibility
Requires host CPython 3.11+ and pytest 8.4+.
For branch coverage with the
sysmon measurement core,
the Python process being measured needs Python 3.14 or newer.
On host Python 3.11–3.13, coverage.py can measure branches with ctrace.
For local Python Workers, the branch coverage requirement applies to
the Python version inside Workerd.
Custom launchers
Implement WasmCoverageTarget[T] to integrate another runtime. See the
custom launcher guide for the snapshot contract.
Development and releases
Install mise and start Docker, then run these commands from the repository root.
mise install
mise build
mise test
mise test runs the full Nox matrix. Run mise test 3.11 to select one host
version. Develop on a feature branch and open a pull request into main.
The CI workflow runs on feature branch pushes
and pull requests. It installs the built wheel on host Python 3.11–3.15 and runs
the package suite, including tests in Pyodide, Workerd, and WASI. The combined
report requires 100% package line and branch coverage across the full suite.
The 3.14 job also runs the examples and uploads their application coverage
reports separately.
After a full local run, open htmlcov/index.html. On GitHub, download the
coverage-wasm-reports and coverage-wasm-example-reports Actions artifacts.
Run mise build-doc to build and validate the documentation with Zensical.
GitHub Actions checks documentation changes on pull requests. Every push to
main runs the package build, test matrix, and coverage gate. After those
checks pass, Actions builds the documentation for the same commit and publishes
it to GitHub Pages.
Releases
The release workflow runs when a package
version changes on protected main or when triggered for an exact version on
main. It tests the commit and tags it. To check out tagged source in a
clone, use git switch --detach v0.2.0.
| Release | Example Git tag | Distribution |
|---|---|---|
| Candidate | v0.2.0-rc.1 |
GitHub Actions artifacts |
| Stable | v0.2.0 |
PyPI and GitHub Actions artifacts |
See the changelog and MIT license.
Metadata
Release files for coverage-wasm 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| coverage_wasm-0.2.0.tar.gz | 32.0 kB | With provenance | Details for coverage_wasm-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| coverage_wasm-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for coverage_wasm-0.2.0-py3-none-any.whl |
Total release size: 50.7 kB
Release files / coverage_wasm-0.2.0.tar.gz
| Download URL | coverage_wasm-0.2.0.tar.gz |
|---|---|
| Size | 32.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b2fa276be4e7b9d4ba46451674df17703466275f9cdd3ee9e5e0ddc52d8f9f27
|
|
BLAKE2b-256 checksum How to use checksums |
37ec93017abe07e7ba4d0f2b4c31d6f1343befdd67cae1019c8f8ebe463ee205
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logRelease files / coverage_wasm-0.2.0-py3-none-any.whl
| Download URL | coverage_wasm-0.2.0-py3-none-any.whl |
|---|---|
| Size | 18.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ae5725c0be2ea025fdb0756f3deb7b946acea44a4ea403db08949550c3d2d71e
|
|
BLAKE2b-256 checksum How to use checksums |
444c2a4a910fff37c8de945e2aa09fa07d31d65a71f105a6497a2db5abd230dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logSecurity for coverage-wasm 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for coverage_wasm-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.