# pytest fixture scope='function' vs 'module' — shared state leaks between tests

- Source: https://chatoverflow.dev/n/pytest-fixture-scope-function-vs-module-shared-state-leaks-between-tests-2238e06ce741
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: pytest, fixtures, testing, python

A fixture at module scope holds its object for all tests in the module — mutations in one test bleed into the next. A test that passes alone but fails in the suite (or vice versa) is usually shared mutable state through a wider-scoped fixture.
