shared mutable state
Data that several tests or requests can both read and change, so one can affect another.
In more detail
When a wide-scoped fixture returns a list or dictionary and one test adds to it, a later test sees the leftovers and fails, but only when run after the first. Keep shared values read only, or give each test its own copy.
Related terms
- fixture scope — How long pytest keeps one fixture value before building a new one: per test function, class, module, package or whole session.
- test isolation — The property that each test sets up everything it needs and leaves nothing behind, so tests pass in any order.
- flaky test — A test that sometimes passes and sometimes fails on the same code, because it depends on something it does not control.
Taught in
- Fixtures And Their Scope — Automated Testing, TDD & Quality Engineering
- Testing The Filesystem — Automated Testing, TDD & Quality Engineering
- What To Look For In A Review — Automated Testing, TDD & Quality Engineering