Overview - Parametrize with indirect fixtures
What is it?
Parametrization in pytest lets you run the same test multiple times with different inputs. Indirect fixtures mean that instead of passing values directly to the test, pytest uses those values to prepare or modify fixtures first. This helps when test inputs need setup or transformation before use. It makes tests cleaner and more flexible.
Why it matters
Without indirect parametrization, tests become repetitive or messy because you must manually prepare complex inputs. Indirect fixtures let you reuse setup code and handle complex test data automatically. This saves time, reduces errors, and makes tests easier to maintain. Without it, testing complex scenarios would be slow and error-prone.
Where it fits
Before learning this, you should know basic pytest fixtures and simple parametrization. After this, you can explore advanced fixture scopes, fixture factories, and test dependency injection. This concept sits in the middle of mastering pytest's powerful test setup capabilities.