doc/en/example/fixtures/test_fixtures_order_autouse.py
raw| 1 | from __future__ import annotations |
| 2 | |
| 3 | import pytest |
| 4 | |
| 5 | |
| 6 | @pytest.fixture |
| 7 | def order(): |
| 8 | return [] |
| 9 | |
| 10 | |
| 11 | @pytest.fixture |
| 12 | def a(order): |
| 13 | order.append("a") |
| 14 | |
| 15 | |
| 16 | @pytest.fixture |
| 17 | def b(a, order): |
| 18 | order.append("b") |
| 19 | |
| 20 | |
| 21 | @pytest.fixture(autouse=True) |
| 22 | def c(b, order): |
| 23 | order.append("c") |
| 24 | |
| 25 | |
| 26 | @pytest.fixture |
| 27 | def d(b, order): |
| 28 | order.append("d") |
| 29 | |
| 30 | |
| 31 | @pytest.fixture |
| 32 | def e(d, order): |
| 33 | order.append("e") |
| 34 | |
| 35 | |
| 36 | @pytest.fixture |
| 37 | def f(e, order): |
| 38 | order.append("f") |
| 39 | |
| 40 | |
| 41 | @pytest.fixture |
| 42 | def g(f, c, order): |
| 43 | order.append("g") |
| 44 | |
| 45 | |
| 46 | def test_order_and_g(g, order): |
| 47 | assert order == ["a", "b", "c", "d", "e", "f", "g"] |