Skip to main content

Pytest plugin for API test coverage analysis

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_api_coverage-0.1.0.tar.gz (122.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_api_coverage-0.1.0-py3-none-any.whl (43.5 kB view details)

Uploaded Python 3

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

Hashes for pytest_api_coverage-0.1.0.tar.gz
Algorithm Hash digest
SHA256 402392879b8e4da14d782cf1f093506f3a71184d072de2492493477dc6ba53d2
MD5 2fd0f24e7d26447347f05622d1f2b374
BLAKE2b-256 81d74391bc4c570107de2d506a37a51f8fd86f19446be9d978080f185e8b6e2f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_api_coverage-0.1.0.tar.gz:

Publisher: publish.yml on anatolybobunov/pytest-api-coverage

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pytest_api_coverage-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_api_coverage-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eeda5d53f255c07e0a4b97851fb9e2fddf37ee5646f73a07295e5b2e8fd19956
MD5 9bc9bfb3fb58cdab9e4599582282aad7
BLAKE2b-256 a280deb858d3708de378dd561ac0018cdb241c4b53f0dd0a45dcf0ec80060967

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page