userver: /data/code/userver/testsuite/pytest_plugins/pytest_userver/config.py Source File
Loading...
Searching...
No Matches
config.py
1"""Supplementary types and functions for @ref pytest_userver.plugins.config."""
2
3from collections.abc import Callable
4import dataclasses
5
6from pytest_userver import fixture_markers
7
8# @cond
9
10
11@dataclasses.dataclass(frozen=True)
12class _ConfigPatchInfo:
13 pass
14
15
16# @endcond
17
18
19def patch(func: Callable[..., object]) -> Callable[..., object]:
20 """
21 Mark a pytest fixture as a static config patch. The fixture will automatically
22 be applied to the service config.
23
24 Apply to the original function, under `@pytest.fixture`.
25
26 Overrides inherit this mark automatically; repeating the decorator is not
27 required, even if the override does not request the original fixture.
28 The override keeps the original marked fixture's position in patch order.
29
30 @snippet samples/static_service/testsuite/conftest.py static config patch
31
32 @see @ref fixture_markers_overrides "Fixture marker inheritance"
33
34 @ingroup userver_testsuite
35 """
36 return fixture_markers.mark(func, _ConfigPatchInfo())