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

Function record_property

src/_pytest/junitxml.py:275–294  ·  view source on GitHub ↗

Add extra properties to the calling test. User properties become part of the test report and are available to the configured reporters, like JUnit XML. The fixture is callable with ``name, value``. The value is automatically XML-encoded. Example:: def test_function(re

(request: FixtureRequest)

Source from the content-addressed store, hash-verified

273
274@pytest.fixture
275def record_property(request: FixtureRequest) -> Callable[[str, object], None]:
276 """Add extra properties to the calling test.
277
278 User properties become part of the test report and are available to the
279 configured reporters, like JUnit XML.
280
281 The fixture is callable with ``name, value``. The value is automatically
282 XML-encoded.
283
284 Example::
285
286 def test_function(record_property):
287 record_property("example_key", 1)
288 """
289 _warn_incompatibility_with_xunit2(request, "record_property")
290
291 def append_property(name: str, value: object) -> None:
292 request.node.user_properties.append((name, value))
293
294 return append_property
295
296
297@pytest.fixture

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected