Skip to content

Commit a92e8d6

Browse files
committed
feat(_ext[spf_demo_fixtures]): add synthetic fixtures for badge demo page
why: The badge demo page needs fixtures that exercise every badge permutation (scope × kind × state) without depending on libtmux's real fixtures, which only cover a subset of combinations. what: - Add spf_demo_fixtures.py with 9 synthetic @pytest.fixture functions covering: plain, session/module/class scope, factory kind, override_hook kind, autouse, deprecated, and two combinations (session+factory, session+autouse)
1 parent 82a5c4b commit a92e8d6

1 file changed

Lines changed: 79 additions & 0 deletions

File tree

docs/_ext/spf_demo_fixtures.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
"""Synthetic fixtures for the sphinx_pytest_fixtures badge demo page.
2+
3+
Each fixture exercises one badge-slot combination so the demo page can show
4+
every permutation side-by-side:
5+
6+
Scope: session | module | class | function (suppressed — no badge)
7+
Kind: resource (suppressed) | factory | override_hook
8+
State: autouse | deprecated (set via RST :deprecated: option)
9+
Combos: session+factory, session+autouse
10+
11+
These fixtures are purely for documentation; they are never collected by
12+
pytest during a real test run (the module is not in the test tree).
13+
"""
14+
15+
from __future__ import annotations
16+
17+
import pytest
18+
19+
20+
@pytest.fixture
21+
def demo_plain() -> str:
22+
"""Plain function-scope resource. Shows FIXTURE badge only."""
23+
return "plain"
24+
25+
26+
@pytest.fixture(scope="session")
27+
def demo_session() -> str:
28+
"""Session-scoped resource. Shows SESSION + FIXTURE badges."""
29+
return "session"
30+
31+
32+
@pytest.fixture(scope="module")
33+
def demo_module() -> str:
34+
"""Module-scoped resource. Shows MODULE + FIXTURE badges."""
35+
return "module"
36+
37+
38+
@pytest.fixture(scope="class")
39+
def demo_class() -> str:
40+
"""Class-scoped resource. Shows CLASS + FIXTURE badges."""
41+
return "class"
42+
43+
44+
@pytest.fixture
45+
def demo_factory() -> type[str]:
46+
"""Return a callable (factory kind). Shows FACTORY + FIXTURE badges."""
47+
return str
48+
49+
50+
@pytest.fixture
51+
def demo_override_hook() -> str:
52+
"""Override hook — customise in conftest.py. Shows OVERRIDE + FIXTURE badges."""
53+
return "override"
54+
55+
56+
@pytest.fixture(autouse=True)
57+
def demo_autouse() -> None:
58+
"""Autouse fixture. Shows AUTO + FIXTURE badges."""
59+
60+
61+
@pytest.fixture
62+
def demo_deprecated() -> str:
63+
"""Return a value (deprecated since 1.0, replaced by :func:`demo_plain`).
64+
65+
This fixture is documented with the ``deprecated`` RST option so the
66+
demo page can show the DEPRECATED + FIXTURE badge combination.
67+
"""
68+
return "deprecated"
69+
70+
71+
@pytest.fixture(scope="session")
72+
def demo_session_factory() -> type[str]:
73+
"""Session-scoped factory. Shows SESSION + FACTORY + FIXTURE badges."""
74+
return str
75+
76+
77+
@pytest.fixture(scope="session", autouse=True)
78+
def demo_session_autouse() -> None:
79+
"""Session-scoped autouse. Shows SESSION + AUTO + FIXTURE badges."""

0 commit comments

Comments
 (0)