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

Function record_xml_attribute

src/_pytest/junitxml.py:305–330  ·  view source on GitHub ↗

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

303
304@pytest.fixture
305def record_xml_attribute(request: FixtureRequest) -> Callable[[str, object], None]:
306 """Add extra xml attributes to the tag for the calling test.
307
308 The fixture is callable with ``name, value``. The value is
309 automatically XML-encoded.
310 """
311 from _pytest.warning_types import PytestExperimentalApiWarning
312
313 request.node.warn(
314 PytestExperimentalApiWarning("record_xml_attribute is an experimental feature")
315 )
316
317 _warn_incompatibility_with_xunit2(request, "record_xml_attribute")
318
319 # Declare noop
320 def add_attr_noop(name: str, value: object) -> None:
321 pass
322
323 attr_func = add_attr_noop
324
325 xml = request.config.stash.get(xml_key, None)
326 if xml is not None:
327 node_reporter = xml.node_reporter(request.node.nodeid)
328 attr_func = node_reporter.add_attribute
329
330 return attr_func
331
332
333def _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