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

Function record_testsuite_property

src/_pytest/junitxml.py:343–376  ·  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

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

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected