Recipes#

Short, runnable answers to "how do I use this with ...". Each page that shows output was produced by running the code on it, and says with which versions.

Page What it covers
FastAPI TestClient and httpx.AsyncClient with dependency-overridden sessions
Flask-SQLAlchemy The test client and db.session
SQLModel Session.exec() and relationships
Litestar TestClient with an overridden session dependency
pytest-asyncio Configuration pitfalls for async tests and fixtures
Budgets for hot endpoints max_queries and max_db_time on the endpoints that matter
Adopting on a legacy codebase Warn mode, a baseline, then fail
CI GitHub Actions, GitLab CI, and why there is no pre-commit hook

The versions used for the output on these pages: Python 3.12, pytest 9.1.1, SQLAlchemy 2.1.4, pytest-queryguard 0.4.0rc4. Messages from older SQLAlchemy releases differ in small ways, for example column aliases in the SQL. Before Python 3.12 a list comprehension is a frame of its own, so a finding raised inside one says in <listcomp> instead of the name of the function.

Edit this page on GitHub