Overview - Fixture dependencies (fixture using fixture)
What is it?
Fixture dependencies in pytest happen when one fixture uses another fixture to prepare test data or setup. This means a fixture can call or require another fixture to run first, creating a chain of setups. It helps organize complex test setups by breaking them into smaller reusable parts. This makes tests cleaner and easier to maintain.
Why it matters
Without fixture dependencies, test setups would be repeated or cluttered inside tests, making them hard to read and update. Fixture dependencies solve this by allowing shared setups to be written once and reused. This saves time, reduces errors, and makes tests more reliable. Without this, tests would be slower to write and more fragile.
Where it fits
Before learning fixture dependencies, you should know basic pytest fixtures and how to write simple tests. After this, you can learn about parameterized fixtures, fixture scopes, and advanced fixture features like autouse and finalizers. Fixture dependencies build on fixture basics and lead to more powerful test organization.