Back to articles
The Python Testing Toolkit: 4 Drop-In Files for Production pytest
How-ToSystems

The Python Testing Toolkit: 4 Drop-In Files for Production pytest

via Dev.toPeyton Green

Every Python project eventually needs the same test infrastructure. You write conftest.py from scratch, reach for the same Hypothesis patterns, copy async fixture code from a Stack Overflow answer that's three major versions out of date. I've done this enough times that I started keeping the files. This week I packaged them up. The Python Testing Toolkit is available now on Gumroad: four production-ready Python files — conftest_production.py , hypothesis_strategies.py , async_test_patterns.py , and parametrize_factories.py . $49, one-time download, MIT license. Here's exactly what's in each one. conftest_production.py — the conftest you'd write if you had eight hours Most conftest.py tutorials show you database fixtures or HTTP mocking. Almost none show both in a form that composes cleanly with async tests, FastAPI dependency overrides, and environment variable isolation. This file handles all of it: # Transaction rollback per test — no cleanup needed def test_creates_user ( db_session

Continue reading on Dev.to

Opens in a new tab

Read Full Article
3 views

Related Articles