Property-based smoke testing for ASGI application routes
Project description
pytest-routes
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
- Discovery - Extracts routes from your ASGI app using framework-specific extractors
- Generation - Creates Hypothesis strategies based on route parameter types
- Execution - Runs property-based tests against each route
- 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
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_routes-0.2.3.tar.gz.
File metadata
- Download URL: pytest_routes-0.2.3.tar.gz
- Upload date:
- Size: 38.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a7a557088dd54bcdebd319c2da392187075bca1ef734f79a4bad7239babeda0
|
|
| MD5 |
5a9954b129dd438d9a4a8de85bf5d43a
|
|
| BLAKE2b-256 |
eb393a06df51c2130873e4c6aea36190b07a9fbe54b04263dff4d575e24bcec6
|
Provenance
The following attestation bundles were made for pytest_routes-0.2.3.tar.gz:
Publisher:
publish.yml on JacobCoffee/pytest-routes
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_routes-0.2.3.tar.gz -
Subject digest:
5a7a557088dd54bcdebd319c2da392187075bca1ef734f79a4bad7239babeda0 - Sigstore transparency entry: 732041609
- Sigstore integration time:
-
Permalink:
JacobCoffee/pytest-routes@c190ff0a847cdb929e14bfbe98eca37138830a94 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/JacobCoffee
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c190ff0a847cdb929e14bfbe98eca37138830a94 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pytest_routes-0.2.3-py3-none-any.whl.
File metadata
- Download URL: pytest_routes-0.2.3-py3-none-any.whl
- Upload date:
- Size: 46.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
796674f031a7e023794512c6616641abf6c7833855057aafd0d3ade8b075efe9
|
|
| MD5 |
d5b60788943eb6408b3d86601a32d936
|
|
| BLAKE2b-256 |
57fb8fbdeffb5376bd0fe4cc31d958a55cafbd49da1afee568641ccf90eb1a1a
|
Provenance
The following attestation bundles were made for pytest_routes-0.2.3-py3-none-any.whl:
Publisher:
publish.yml on JacobCoffee/pytest-routes
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_routes-0.2.3-py3-none-any.whl -
Subject digest:
796674f031a7e023794512c6616641abf6c7833855057aafd0d3ade8b075efe9 - Sigstore transparency entry: 732041610
- Sigstore integration time:
-
Permalink:
JacobCoffee/pytest-routes@c190ff0a847cdb929e14bfbe98eca37138830a94 -
Branch / Tag:
refs/tags/v0.2.3 - Owner: https://github.com/JacobCoffee
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c190ff0a847cdb929e14bfbe98eca37138830a94 -
Trigger Event:
push
-
Statement type: