Skip to main content

Property-based smoke testing for ASGI application routes

Project description

pytest-routes

PyPI Python Version License

Property-based smoke testing for ASGI application routes.

Overview

pytest-routes automatically discovers routes from your ASGI application and performs randomized smoke testing using Hypothesis. It works with any ASGI framework, with first-class support for Litestar.

Key Features

  • Automatic Route Discovery - Extracts routes directly from your ASGI app
  • Property-Based Testing - Uses Hypothesis to generate diverse test inputs
  • Framework Agnostic - Works with Litestar, FastAPI, Starlette, and any ASGI app
  • Configurable - Filter routes, set examples per route, customize validation
  • Zero Config - Works out of the box with sensible defaults

Installation

# With pip
pip install pytest-routes

# With uv
uv add pytest-routes

# With framework extras
uv add "pytest-routes[litestar]"
uv add "pytest-routes[fastapi]"

Quick Start

# Run smoke tests on your ASGI app
pytest --routes --routes-app myapp:app

# With options
pytest --routes --routes-app myapp:app --routes-max-examples 50

Or define your app as a fixture:

# conftest.py
import pytest
from myapp import create_app

@pytest.fixture(scope="session")
def app():
    return create_app()
pytest --routes

Configuration

CLI Options

Option Description Default
--routes Enable route smoke testing False
--routes-app Import path to ASGI app -
--routes-max-examples Max Hypothesis examples per route 100
--routes-exclude Comma-separated patterns to exclude /health,/metrics,...
--routes-include Comma-separated patterns to include -
--routes-methods HTTP methods to test GET,POST,PUT,PATCH,DELETE
--routes-seed Random seed for reproducibility -

pyproject.toml

[tool.pytest-routes]
app = "myapp:app"
max_examples = 100
exclude = ["/health", "/metrics", "/docs"]
methods = ["GET", "POST"]

Supported Frameworks

Framework Status Notes
Litestar First-class Full type extraction
FastAPI Supported Via Starlette
Starlette Supported Base ASGI support

How It Works

  1. Discovery - Extracts routes from your ASGI app using framework-specific extractors
  2. Generation - Creates Hypothesis strategies based on route parameter types
  3. Execution - Runs property-based tests against each route
  4. Validation - Checks responses meet smoke test criteria (no 5xx, etc.)

Documentation

Full documentation available at jacobcoffee.github.io/pytest-routes

License

MIT License - see LICENSE

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_routes-0.3.0.tar.gz (49.2 kB view details)

Uploaded Source

Built Distribution

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

pytest_routes-0.3.0-py3-none-any.whl (60.6 kB view details)

Uploaded Python 3

File details

Details for the file pytest_routes-0.3.0.tar.gz.

File metadata

  • Download URL: pytest_routes-0.3.0.tar.gz
  • Upload date:
  • Size: 49.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pytest_routes-0.3.0.tar.gz
Algorithm Hash digest
SHA256 0d96b91c8b2ec2c1f9de2bae636811b61dbe2f6635b257d2625aee2ffc6a7932
MD5 28e5cec553f588fad010deb96859166a
BLAKE2b-256 c7ed81f29f7b483e98261ac06d3493eab39cec71dbc65f98e558f723063d92af

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_routes-0.3.0.tar.gz:

Publisher: publish.yml on JacobCoffee/pytest-routes

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_routes-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: pytest_routes-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 60.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pytest_routes-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2a3bbd25cfe55bdb1a4e61faee681d0152f34532c4efcf0cc49204e5b24d27a6
MD5 09f8fba589eba77c8244c5f0fe93f1e0
BLAKE2b-256 f982818a7400b51b1b23088817dd22d4fd94e4df821dd980ac94c06e50a626a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pytest_routes-0.3.0-py3-none-any.whl:

Publisher: publish.yml on JacobCoffee/pytest-routes

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