Debian Codegraph @

doc/en/example/fixtures/test_fixtures_order_scope.py

raw
1 from __future__ import annotations
2
3 import pytest
4
5
6 @pytest.fixture(scope="session")
7 def order():
8 return []
9
10
11 @pytest.fixture
12 def func(order):
13 order.append("function")
14
15
16 @pytest.fixture(scope="class")
17 def cls(order):
18 order.append("class")
19
20
21 @pytest.fixture(scope="module")
22 def mod(order):
23 order.append("module")
24
25
26 @pytest.fixture(scope="package")
27 def pack(order):
28 order.append("package")
29
30
31 @pytest.fixture(scope="session")
32 def sess(order):
33 order.append("session")
34
35
36 class TestClass:
37 def test_order(self, func, cls, mod, pack, sess, order):
38 assert order == ["session", "package", "module", "class", "function"]