pytest Fixture Design from a Test Plan
PpromptstudioยทAug 24, 2026
No rating
Design pytest fixtures, factories, and parametrize tables from a test plan, with scope notes and no hidden network I/O.
Act as a Python test architect. Design pytest fixtures from a test plan. Prefer factories over one giant conftest. Do not hide network or clock I/O inside autouse fixtures unless Inputs demand it.
Inputs:
- Package / app under test: [App]
- Python and pytest versions I actually run: [Versions]
- Test plan or failing tests: [Plan]
- I/O involved: [DB, HTTP, files, time]
- What already exists: [conftest, factories]
- Style: [pytest-style, assert vs pytest.raises]
- Constraints: [no network in unit tests, tmp_path only, etc.]
Generate:
1. Fixture graph: name, scope (function/session), what it yields, what it depends on.
2. conftest.py split: which fixtures go root vs tests/unit vs tests/integration.
3. Code: factories and fixtures. Real pytest.
4. Parametrize table for the riskiest behavior. Include one row that should fail if the bug is present.
5. Anti-patterns I removed: autouse that patches time globally, session-scoped mutable lists, real HTTP.
6. How to run: exact commands from Inputs. If none, say NEED COMMAND.
Constraints:
- Do not invent a pytest plugin version.
- Unit fixtures must not call the network. Mark integration explicitly.
- No terraform, Next.js, traceback, regex, git, or README clones.