Writes a conftest file that collects and executes a dummy yaml test. Taken from the docs, but stripped down to the bare minimum, useful for tests which needs custom items collected.
(pytester: Pytester)
| 105 | |
| 106 | @pytest.fixture |
| 107 | def dummy_yaml_custom_test(pytester: Pytester): |
| 108 | """Writes a conftest file that collects and executes a dummy yaml test. |
| 109 | |
| 110 | Taken from the docs, but stripped down to the bare minimum, useful for |
| 111 | tests which needs custom items collected. |
| 112 | """ |
| 113 | pytester.makeconftest( |
| 114 | """ |
| 115 | import pytest |
| 116 | |
| 117 | def pytest_collect_file(parent, file_path): |
| 118 | if file_path.suffix == ".yaml" and file_path.name.startswith("test"): |
| 119 | return YamlFile.from_parent(path=file_path, parent=parent) |
| 120 | |
| 121 | class YamlFile(pytest.File): |
| 122 | def collect(self): |
| 123 | yield YamlItem.from_parent(name=self.path.name, parent=self) |
| 124 | |
| 125 | class YamlItem(pytest.Item): |
| 126 | def runtest(self): |
| 127 | pass |
| 128 | """ |
| 129 | ) |
| 130 | pytester.makefile(".yaml", test1="") |
| 131 | |
| 132 | |
| 133 | @pytest.fixture |
nothing calls this directly
no test coverage detected