Debian Codegraph @

tests/conftest.py

raw symbols SCIP
1 """Pytest configuration file for the tests package."""
2
3 from collections.abc import Generator
4
5 import pytest
6
7 from tests.common import YAML_CONFIG_FILE, patch_yaml_files
8
9
10 @pytest.fixture
11 def mock_yaml() -> str:
12 """
13 Fixture to parametrize the content of test yaml file.
14
15 To set yaml content, tests can be marked with:
16 @pytest.mark.parametrize("mock_yaml", ["..."])
17 Add the `mock_yaml: None` fixture to the test.
18 """
19 return ""
20
21
22 @pytest.fixture
23 def mock_yaml_files(mock_yaml: str) -> dict[str, str]:
24 """
25 Fixture to parametrize multiple yaml configuration files.
26
27 To set the YAML files to patch, tests can be marked with:
28 @pytest.mark.parametrize(
29 "mock_yaml_files", [{"configuration.yaml": "..."}]
30 )
31 Add the `mock_yaml_files: None` fixture to the test.
32 """
33 return {YAML_CONFIG_FILE: mock_yaml}
34
35
36 @pytest.fixture
37 def patch_yaml_config(mock_yaml_files: dict[str, str]) -> Generator[None]:
38 """
39 Fixture to mock the content of the yaml configuration files.
40
41 Patches yaml configuration files using the `mock_yaml`
42 and `mock_yaml_files` fixtures.
43 """
44 with patch_yaml_files(mock_yaml_files):
45 yield