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

Function record_testsuite_property

src/_pytest/junitxml.py:336–371  ·  view source on GitHub ↗

Record a new `` `` tag as child of the root `` ``. This is suitable to writing global information regarding the entire test suite, and is compatible with ``xunit2`` JUnit family. This is a ``session``-scoped fixture which is called with ``(name, value)``. Example:

(request: FixtureRequest)

Source from the content-addressed store, hash-verified

334
335@pytest.fixture(scope="session")
336def record_testsuite_property(request: FixtureRequest) -> Callable[[str, object], None]:
337 """Record a new ``<property>`` tag as child of the root ``<testsuite>``.
338
339 This is suitable to writing global information regarding the entire test
340 suite, and is compatible with ``xunit2`` JUnit family.
341
342 This is a ``session``-scoped fixture which is called with ``(name, value)``. Example:
343
344 .. code-block:: python
345
346 def test_foo(record_testsuite_property):
347 record_testsuite_property("ARCH", "PPC")
348 record_testsuite_property("STORAGE_TYPE", "CEPH")
349
350 :param name:
351 The property name.
352 :param value:
353 The property value. Will be converted to a string.
354
355 .. warning::
356
357 Currently this fixture **does not work** with the
358 `pytest-xdist <https://github.com/pytest-dev/pytest-xdist>`__ plugin. See
359 :issue:`7767` for details.
360 """
361 __tracebackhide__ = True
362
363 def record_func(name: str, value: object) -> None:
364 """No-op function in case --junit-xml was not passed in the command-line."""
365 __tracebackhide__ = True
366 _check_record_param_type("name", name)
367
368 xml = request.config.stash.get(xml_key, None)
369 if xml is not None:
370 record_func = xml.add_global_property
371 return record_func
372
373
374def pytest_addoption(parser: Parser) -> None:

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…