Pytest patterns for Python APIs -- httpx AsyncClient, conftest fixtures, database isolation, parametrize edge cases, error response testing, auth flows, factory fixtures
99
99%
Does it follow best practices?
Impact
100%
1.23xAverage score across 5 eval scenarios
Passed
No known issues
FastAPI test client setup
Uses AsyncClient
100%
100%
Uses ASGITransport
100%
100%
asyncio_mode auto
100%
100%
pytest-asyncio installed
100%
100%
httpx installed
100%
100%
Fixture in conftest.py
100%
100%
Function-scoped client
100%
100%
base_url set
100%
100%
No requests/urllib import
100%
100%
Database fixture isolation
Session-scoped engine
100%
100%
Function-scoped session
100%
100%
Cleanup before yield
100%
100%
autouse cleanup
0%
100%
Dependency override
100%
100%
No database mock
100%
100%
Override cleared after
100%
100%
in-memory or transaction isolation
80%
100%
Fixtures in conftest
100%
100%
Factory fixtures and parametrize
Factory fixture defined
0%
100%
Factory accepts overrides
0%
100%
Factory used with variations
0%
100%
parametrize for validation
100%
100%
parametrize covers 3+ cases
100%
100%
No hardcoded duplicate data
60%
100%
Error body asserted
0%
100%
Duplicate email test
100%
100%
Fixtures in conftest
100%
100%
Error response and schema testing
404 body asserted
100%
100%
422 body asserted
50%
100%
409 tested
100%
100%
404 on delete
100%
100%
List response structure
100%
100%
Individual item structure
100%
100%
Password not exposed
100%
100%
Password hash not exposed
100%
100%
Invalid JSON tested
100%
100%
Error response is JSON
100%
100%
Multiple error types covered
100%
100%
Auth flows and monkeypatch
No-token test
100%
100%
Invalid token test
100%
100%
Valid token grants access
100%
100%
auth_headers fixture
100%
100%
auth_headers in conftest
100%
100%
monkeypatch for SMTP failure
0%
100%
No unittest.mock for simple patch
0%
100%
503 on service failure
100%
100%
Login flow in fixture
100%
100%
asyncio_mode config
100%
100%
Table of Contents