test isolation
The property that each test sets up everything it needs and leaves nothing behind, so tests pass in any order.
In more detail
Isolated tests can run alone, in parallel or shuffled with the same result. Function-scoped fixtures, temporary paths, transactions that roll back and disposable containers are all ways to achieve it.
Related terms
- shared mutable state — Data that several tests or requests can both read and change, so one can affect another.
- fixture scope — How long pytest keeps one fixture value before building a new one: per test function, class, module, package or whole session.
- tmp_path — A built-in pytest fixture that gives each test its own fresh temporary directory as a pathlib.Path.
- 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
- Flaky Tests And How To Kill Them — Automated Testing, TDD & Quality Engineering
- Testing With Real Databases — Automated Testing, TDD & Quality Engineering