Record a new ``<property>`` tag as child of the root ``<testsuite>``. 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)
| 334 | |
| 335 | @pytest.fixture(scope=class="st">"session") |
| 336 | def record_testsuite_property(request: FixtureRequest) -> Callable[[str, object], None]: |
| 337 | class="st">"""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(class="st">"ARCH", class="st">"PPC") |
| 348 | record_testsuite_property(class="st">"STORAGE_TYPE", class="st">"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 | class="st">""" |
| 361 | __tracebackhide__ = True |
| 362 | |
| 363 | def record_func(name: str, value: object) -> None: |
| 364 | class="st">""class="st">"No-op function in case --junit-xml was not passed in the command-line."class="st">"" |
| 365 | __tracebackhide__ = True |
| 366 | _check_record_param_type(class="st">"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 | |
| 374 | def pytest_addoption(parser: Parser) -> None: |