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)
| 303 | |
| 304 | @pytest.fixture |
| 305 | def 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 | |
| 333 | def _check_record_param_type(param: str, v: str) -> None: |
nothing calls this directly
no test coverage detected