MCPcopy
hub / github.com/pytest-dev/pytest / record_xml_attribute

Function record_xml_attribute

src/_pytest/junitxml.py:298–323  ·  src/_pytest/junitxml.py::record_xml_attribute

Add extra xml attributes to the tag for the calling test. The fixture is callable with ``name, value``. The value is automatically XML-encoded.

(request: FixtureRequest)

Source from the content-addressed store, hash-verified

296
297@pytest.fixture
298def record_xml_attribute(request: FixtureRequest) -> Callable[[str, object], None]:
299 class="st">"""Add extra xml attributes to the tag for the calling test.
300
301 The fixture is callable with ``name, value``. The value is
302 automatically XML-encoded.
303 class="st">"""
304 from _pytest.warning_types import PytestExperimentalApiWarning
305
306 request.node.warn(
307 PytestExperimentalApiWarning(class="st">"record_xml_attribute is an experimental feature")
308 )
309
310 _warn_incompatibility_with_xunit2(request, class="st">"record_xml_attribute")
311
312 class="cm"># Declare noop
313 def add_attr_noop(name: str, value: object) -> None:
314 pass
315
316 attr_func = add_attr_noop
317
318 xml = request.config.stash.get(xml_key, None)
319 if xml is not None:
320 node_reporter = xml.node_reporter(request.node.nodeid)
321 attr_func = node_reporter.add_attribute
322
323 return attr_func
324
325
326def _check_record_param_type(param: str, v: str) -> None:

Callers

nothing calls this directly

Calls 5

node_reporterMethod · 0.80
warnMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected