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)
| 296 | |
| 297 | @pytest.fixture |
| 298 | def 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 | |
| 326 | def _check_record_param_type(param: str, v: str) -> None: |
nothing calls this directly
no test coverage detected