Overview - Conftest fixtures (shared across files)
What is it?
Conftest fixtures in pytest are special functions that provide reusable setup or data for tests. They live in a file named conftest.py and can be shared across multiple test files in the same directory or subdirectories. This allows tests to use common resources without repeating code. They help organize and simplify test setup in larger projects.
Why it matters
Without conftest fixtures, each test file would need to duplicate setup code, making tests harder to maintain and more error-prone. Sharing fixtures across files saves time, reduces bugs, and keeps tests consistent. It makes adding or changing test setup easier, improving overall test quality and developer productivity.
Where it fits
Before learning conftest fixtures, you should understand basic pytest fixtures and how to write simple tests. After mastering conftest fixtures, you can explore advanced fixture scopes, parameterization, and plugin development to customize pytest behavior.