Pytest plugin for API test coverage analysis
Project description
pytest-api-coverage
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
requestsandhttpxlibraries - 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
requestsandhttpx, 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_api_coverage-0.1.0.tar.gz.
File metadata
- Download URL: pytest_api_coverage-0.1.0.tar.gz
- Upload date:
- Size: 122.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
402392879b8e4da14d782cf1f093506f3a71184d072de2492493477dc6ba53d2
|
|
| MD5 |
2fd0f24e7d26447347f05622d1f2b374
|
|
| BLAKE2b-256 |
81d74391bc4c570107de2d506a37a51f8fd86f19446be9d978080f185e8b6e2f
|
Provenance
The following attestation bundles were made for pytest_api_coverage-0.1.0.tar.gz:
Publisher:
publish.yml on anatolybobunov/pytest-api-coverage
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_api_coverage-0.1.0.tar.gz -
Subject digest:
402392879b8e4da14d782cf1f093506f3a71184d072de2492493477dc6ba53d2 - Sigstore transparency entry: 1171472694
- Sigstore integration time:
-
Permalink:
anatolybobunov/pytest-api-coverage@f442f5b34400be5408143f5ef8213e98729efc0b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/anatolybobunov
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f442f5b34400be5408143f5ef8213e98729efc0b -
Trigger Event:
release
-
Statement type:
File details
Details for the file pytest_api_coverage-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pytest_api_coverage-0.1.0-py3-none-any.whl
- Upload date:
- Size: 43.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eeda5d53f255c07e0a4b97851fb9e2fddf37ee5646f73a07295e5b2e8fd19956
|
|
| MD5 |
9bc9bfb3fb58cdab9e4599582282aad7
|
|
| BLAKE2b-256 |
a280deb858d3708de378dd561ac0018cdb241c4b53f0dd0a45dcf0ec80060967
|
Provenance
The following attestation bundles were made for pytest_api_coverage-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on anatolybobunov/pytest-api-coverage
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_api_coverage-0.1.0-py3-none-any.whl -
Subject digest:
eeda5d53f255c07e0a4b97851fb9e2fddf37ee5646f73a07295e5b2e8fd19956 - Sigstore transparency entry: 1171472707
- Sigstore integration time:
-
Permalink:
anatolybobunov/pytest-api-coverage@f442f5b34400be5408143f5ef8213e98729efc0b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/anatolybobunov
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f442f5b34400be5408143f5ef8213e98729efc0b -
Trigger Event:
release
-
Statement type: