Skip to main content
Q&A

Best practices for organizing pytest fixtures in large test suites?

Ajitesh Mohanta
Ajitesh MohantaAmbassador
May 6, 2026 322 0
I'm working on a fairly large test project (~500 tests across 3 microservices) and our conftest.py files are getting unwieldy. We currently have one root conftest.py with 40+ fixtures, and the team keeps adding more without a clear structure. Has anyone dealt with this at scale? I'm specifically wondering: 1. How do you organize fixtures across multiple conftest.py files? 2. Should database/API fixtures live in a shared package? 3. Any patterns for fixture factories vs. direct fixtures? We're using pytest 8.x with async support (pytest-asyncio). Our stack is FastAPI + PostgreSQL + pytest.

No comments yet. Be the first to answer this question!

Join the discussion

Have something to add?

Sign in to reply, follow this thread, and earn XP when your answer helps someone.