Examples¶
Live demos¶
Bulk autodoc¶
-
Plain function-scope resource. Shows FIXTURE badge only.
-
Session-scoped resource. Shows SESSION + FIXTURE badges.
Note
Created once per test session and shared across all tests. Requesting this fixture does not create a new instance per test.
-
Module-scoped resource. Shows MODULE + FIXTURE badges.
-
Class-scoped resource. Shows CLASS + FIXTURE badges.
Return a callable (factory kind). Shows FACTORY + FIXTURE badges.
def test_example(demo_factory: type[str]) -> None: obj = demo_factory() assert obj is not None
-
Override hook — customise in conftest.py. Shows OVERRIDE + FIXTURE badges.
-
Autouse fixture. Shows AUTO + FIXTURE badges.
- Autouse:
yes — runs automatically for every test
Note
No request needed — this fixture runs automatically for every test.
-
Return a value (deprecated since 1.0, replaced by demo_plain).
This fixture is documented with the
deprecatedRST option so the demo page can show the DEPRECATED + FIXTURE badge combination.
Session-scoped factory. Shows SESSION + FACTORY + FIXTURE badges.
Note
Created once per test session and shared across all tests. Requesting this fixture does not create a new instance per test.
def test_example(demo_session_factory: type[str]) -> None: obj = demo_session_factory() assert obj is not None
-
Session-scoped autouse. Shows SESSION + AUTO + FIXTURE badges.
Note
Created once per test session and shared across all tests. Requesting this fixture does not create a new instance per test.
- Autouse:
yes — runs automatically for every test
Note
No request needed — this fixture runs automatically for every test.
Plugin page helper¶
Install
$ pip install sphinx-autodoc-pytest-fixtures
Note
pytest auto-detects this plugin through the pytest11 entry point. Its fixtures are available without extra conftest.py imports.
Add project-specific usage notes here. The helper renders the install section, autodiscovery note, and full fixture summary/reference.
Fixture Reference
Plain function-scope resource. Shows FIXTURE badge only.
Session-scoped resource. Shows SESSION + FIXTURE badges.
Note
Created once per test session and shared across all tests. Requesting this fixture does not create a new instance per test.
Module-scoped resource. Shows MODULE + FIXTURE badges.
Class-scoped resource. Shows CLASS + FIXTURE badges.
Return a callable (factory kind). Shows FACTORY + FIXTURE badges.
def test_example(demo_factory: type[str]) -> None: obj = demo_factory() assert obj is not None
Override hook — customise in conftest.py. Shows OVERRIDE + FIXTURE badges.
Autouse fixture. Shows AUTO + FIXTURE badges.
- Autouse:
yes — runs automatically for every test
Note
No request needed — this fixture runs automatically for every test.
Return a value (deprecated since 1.0, replaced by demo_plain).
This fixture is documented with the
deprecatedRST option so the demo page can show the DEPRECATED + FIXTURE badge combination.
Session-scoped factory. Shows SESSION + FACTORY + FIXTURE badges.
Note
Created once per test session and shared across all tests. Requesting this fixture does not create a new instance per test.
def test_example(demo_session_factory: type[str]) -> None: obj = demo_session_factory() assert obj is not None
Session-scoped autouse. Shows SESSION + AUTO + FIXTURE badges.
Note
Created once per test session and shared across all tests. Requesting this fixture does not create a new instance per test.
- Autouse:
yes — runs automatically for every test
Note
No request needed — this fixture runs automatically for every test.
When to use auto-pytest-plugin¶
Use this directive for a standard pytest plugin page where you want consistent
house-style: an install section, the pytest11 autodiscovery note, and a
generated fixture summary and reference.
autofixtures options¶
Option |
Default |
Description |
|---|---|---|
|
|
|
|
(empty) |
Comma-separated fixture names to skip |
|
(off) |
Emit descriptions without registering fixtures in the domain index; use when the same module is documented twice on one page |
Single autodoc entries¶
-
Plain function-scope resource. Shows FIXTURE badge only.
Session-scoped factory. Shows SESSION + FACTORY + FIXTURE badges.
Note
Created once per test session and shared across all tests. Requesting this fixture does not create a new instance per test.
def test_example(demo_session_factory: type[str]) -> None: obj = demo_session_factory() assert obj is not None
Manual domain directive¶
-
fixture spf_demo_fixtures.demo_deprecatedfixture spf_demo_fixtures.demo_deprecated
Return a deprecated value. Use
demo_plaininstead.Warning
Deprecated since version 1.0. Use
demo_plaininstead.
Copyable config snippet
extensions = [
"sphinx_autodoc_pytest_fixtures",
]