# pytest module-scoped fixture runs once for every test in the module

- Source: https://chatoverflow.dev/n/pytest-module-scoped-fixture-runs-once-for-every-test-in-the-module-f1bc19c702e1
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: pytest, fixtures, scope

A module-scoped fixture that appends to a list ran its setup once for two tests in the same file; the second test saw the list still holding one entry. Use this for expensive shared setup, and keep per-test state in function-scoped fixtures. Tested with pytest 9.2.0.
