Skip to main content

pytest-api-coverage

PyPI version Python versions License: MIT CI

Pytest plugin for API test coverage analysis. Automatically intercepts HTTP requests during test execution, compares them against OpenAPI specifications, and generates detailed coverage reports.

Features

  • Automatic HTTP interception — captures requests from requests and httpx libraries
  • Swagger/OpenAPI support — works with JSON and YAML specifications (local files or URLs)
  • Multiple report formats — JSON, CSV, and HTML reports
  • pytest-xdist support — works with parallel test execution
  • Origin filtering — filter coverage by base URL or allowlist
  • Split by origin — generate separate coverage per API origin
  • Async support — intercepts both requests and httpx, including async httpx clients
  • Multi-spec mode — measure coverage across multiple APIs in a single test run

Installation

Requires Python 3.11+ and pytest 7.0+.

# If your project uses requests
pip install pytest-api-coverage[requests]

# If your project uses httpx
pip install pytest-api-coverage[httpx]

# If your project uses both
pip install pytest-api-coverage[requests,httpx]

See Installation Guide for details.

Quick Start

# Basic usage with local spec file
pytest tests/ --coverage-spec=swagger.json

# Using remote spec URL
pytest tests/ --coverage-spec=https://api.example.com/swagger.json

# With parallel execution
pytest tests/ -n 4 --coverage-spec=swagger.json

Documentation

Guide Description
Installation Requirements, install options, verification
Usage Guide CLI options and examples
Configuration Reference pytest.ini setup, multi-spec config
Coverage Reports Report formats and result interpretation
API Reference Public Python API for programmatic access
Architecture How the plugin works internally
Troubleshooting Common issues and fixes
Changelog Release history
Contributing Development setup and guidelines

Contributing

Contributions are welcome. See CONTRIBUTING.md for development setup and guidelines.

License

MIT — see LICENSE for details.

Release files for pytest-api-coverage 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-api-coverage 0.1.0
File Size Uploaded
pytest_api_coverage-0.1.0.tar.gz 122.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-api-coverage 0.1.0
File Interpreter ABI Platform
pytest_api_coverage-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 165.5 kB

Release files / pytest_api_coverage-0.1.0.tar.gz

Download URL pytest_api_coverage-0.1.0.tar.gz
Size 122.1 kB
Tags Source
SHA-256 checksum
How to use checksums
402392879b8e4da14d782cf1f093506f3a71184d072de2492493477dc6ba53d2
BLAKE2b-256 checksum
How to use checksums
81d74391bc4c570107de2d506a37a51f8fd86f19446be9d978080f185e8b6e2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Mar 24, 2026.

Transparency log

Release files / pytest_api_coverage-0.1.0-py3-none-any.whl

Download URL pytest_api_coverage-0.1.0-py3-none-any.whl
Size 43.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eeda5d53f255c07e0a4b97851fb9e2fddf37ee5646f73a07295e5b2e8fd19956
BLAKE2b-256 checksum
How to use checksums
a280deb858d3708de378dd561ac0018cdb241c4b53f0dd0a45dcf0ec80060967
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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 Mar 24, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page