Show HN: Pytest-fastprom – Turn your SLOs into pytest assertions

lujeni_1 pts0 comments

GitHub - Lujeni/pytest-fastprom: Turn your SLOs into pytest assertions. · GitHub

/" data-turbo-transient="true" />

Skip to content

Search or jump to...

Search code, repositories, users, issues, pull requests...

-->

Search

Clear

Search syntax tips

Provide feedback

--><br>We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Cancel

Submit feedback

Saved searches

Use saved searches to filter your results more quickly

-->

Name

Query

To see all available qualifiers, see our documentation.

Cancel

Create saved search

Sign in

/;ref_cta:Sign up;ref_loc:header logged out"}"<br>Sign up

Appearance settings

Resetting focus

You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.

Dismiss alert

{{ message }}

Lujeni

pytest-fastprom

Public

Notifications<br>You must be signed in to change notification settings

Fork<br>19

Star<br>31

main

BranchesTags

Go to file

CodeOpen more actions menu

Folders and files<br>NameNameLast commit message<br>Last commit date<br>Latest commit

History<br>15 Commits<br>15 Commits

.github/workflows

.github/workflows

docs

docs

examples/items_api

examples/items_api

pytest_fastprom

pytest_fastprom

tests

tests

.pre-commit-config.yaml

.pre-commit-config.yaml

CHANGELOG.md

CHANGELOG.md

README.md

README.md

conftest.py

conftest.py

mise.toml

mise.toml

mkdocs.yml

mkdocs.yml

pyproject.toml

pyproject.toml

uv.lock

uv.lock

View all files

Repository files navigation

pytest-fastprom

Turn your SLOs into pytest assertions.

Smoketest your FastAPI against the latency and error budgets you actually promised. Built on the Prometheus metrics your app already exposes, not wall-clock timeit guesses.

def test_home_meets_slo(instrumented_client, metrics):<br>instrumented_client.get("/")<br>metrics.assert_p99_below(1.0, handler="/")<br>metrics.assert_no_server_errors()

Or declare the SLO right on the test:

@pytest.mark.metrics(p99_below=1.0, min_requests=3, no_errors=True)<br>def test_route_within_budget(instrumented_client):<br>for _ in range(3):<br>instrumented_client.get("/")

Features

Prometheus-native . Asserts on real histogram metrics, not stopwatch timing.

Isolated registry per test. No metric leaks between tests.

SLO assertions on P50, P99, request counts, and error rates.

Custom metrics . assert_metric checks any Counter/Gauge/Histogram your app exposes.

Error budgets . max_error_rate / max_4xx_rate assert a ratio, not just a zero count.

Regression detection . Save a baseline, fail the build when it drifts.

Environment-aware baselines . Saved runs record git commit + machine info and warn on cross-machine comparisons.

Warmup support. Cold starts stay out of your measurement window.

Install

uv add --dev pytest-fastprom<br># or<br>pip install pytest-fastprom

Docs

Full guide, marker reference, and regression detection: https://lujeni.github.io/pytest-fastprom/.

About

Turn your SLOs into pytest assertions.

lujeni.github.io/pytest-fastprom/

Topics

prometheus

pytest

pytest-plugin

performance-testing

smoke-test

fastapi

Resources

Readme

Uh oh!

There was an error while loading. Please reload this page.

Activity

Stars

31<br>stars

Watchers

watching

Forks

19<br>forks

Report repository

Releases

0.2.0

Latest

May 22, 2026

Packages

Uh oh!

There was an error while loading. Please reload this page.

Contributors

Uh oh!

There was an error while loading. Please reload this page.

Languages

Python<br>100.0%

You can’t perform that action at this time.

pytest fastprom metrics github reload commit

Related Articles