MCPcopy Create free account
hub / github.com/pytest-dev/pytest / dummy_yaml_custom_test

Function dummy_yaml_custom_test

testing/conftest.py:107–130  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

105
106@pytest.fixture
107def 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

Callers

nothing calls this directly

Calls 2

makeconftestMethod · 0.45
makefileMethod · 0.45

Tested by

no test coverage detected