Climbing Out of Fixture Hell, Indirectly
summary
Shows concrete pytest code using indirect=True parametrization to replace dozens of specialized fixtures with one consolidated fixture per data type, turning three duplicate tests into one and cutting a 6s total DB setup cost to ~2s by using a module-scoped connection + function-scoped data pattern. Demonstrates request.param usage, multi-param runs, default values and readable test ids, warns against multi-level indirection that creates a fixture maze, and recommends factory fixtures, lazy setup and avoiding a giant god fixture.
AI-written summary · about
chapters (11)
- 0:00Introduction
- 1:08Test simplicity as code grows
- 3:24Fixture explosion from state
- 5:25Indirect parameterization with PyTest
- 7:50Tests describe needs not setup
- 10:05Consolidate fixtures with indirect
- 12:03Limits of multi-level parameterization
- 14:25Fixture explosion versus maze
- 14:53Scope confusion in expensive fixtures
- 17:17Isolating mutable data in function scope
- 19:13Maintainable test clarity
related talks
21mDon't just test, my friend, test better
24mGiven this, assert that: fluent testing using fixtures and properties
29mSecrets of the testing masters
41mFrom pytest to Go: a fixture-based test environment
21mMultiply your Testing Effectiveness with Parameterized Testing
32mpytest for unittesters
44mThey are not unit tests: a survey of unit-testing anti-patterns
38mCakePHP Test Fixture Factories
