← Back to all products
$29
Python Testing Toolkit
Pytest fixtures, factories, mocking patterns, property-based testing, and CI integration for comprehensive test suites.
MarkdownJSONRedis
📁 File Structure 18 files
python-testing-toolkit/
├── LICENSE
├── README.md
├── configs/
│ ├── .coveragerc
│ ├── pytest.ini
│ └── tox.ini
├── examples/
│ ├── test_api_example.py
│ └── test_model_example.py
├── guides/
│ └── python-testing-guide.md
└── src/
├── fixtures/
│ ├── api_client.py
│ ├── database.py
│ ├── factories.py
│ └── mocks.py
├── helpers/
│ ├── assertions.py
│ ├── coverage_reporter.py
│ └── snapshot.py
└── plugins/
├── slow_test_reporter.py
└── test_ordering.py
📖 Documentation Preview README excerpt
Python Testing Toolkit
A comprehensive collection of pytest fixtures, helpers, plugins, and configurations for writing robust Python tests. Designed for real-world applications with databases, APIs, external services, and complex data models.
Features
- Database fixtures with automatic setup, teardown, and session management
- HTTP client fixtures for authenticated and anonymous API testing
- Factory functions for generating test data (User, Order, etc.)
- Common mocks for Redis, S3, and SMTP services
- Custom assertions for dictionaries, datetimes, and domain logic
- Snapshot testing for comparing JSON output across test runs
- Coverage reporting with custom HTML and summary output
- pytest plugins for slow test reporting and test ordering
Quick Start
Install Dependencies
pip install pytest pytest-asyncio httpx factory-boy freezegun coverage
Use Database Fixtures
from fixtures.database import db_session, test_db
def test_create_user(db_session):
"""Test user creation with an auto-rolled-back session."""
user = User(name="Alice", email="alice@example.com")
db_session.add(user)
db_session.flush()
assert user.id is not None
assert db_session.query(User).count() == 1
# Session is rolled back after the test — no cleanup needed
Use API Client Fixtures
from fixtures.api_client import auth_client, anon_client
async def test_protected_endpoint(auth_client):
"""Authenticated client includes a valid Bearer token."""
response = await auth_client.get("/api/v1/profile")
assert response.status_code == 200
assert "email" in response.json()
async def test_unauthorized_access(anon_client):
"""Anonymous client should receive 401."""
response = await anon_client.get("/api/v1/profile")
assert response.status_code == 401
Use Factories
from fixtures.factories import UserFactory, OrderFactory
*... continues with setup instructions, usage examples, and more.*