From 111c6d6a22a629225f8cab9c6a86da65d1bb9cab Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Tue, 27 Feb 2018 17:19:57 -0300 Subject: [PATCH] Improve pytestconfig and add record_xml_property --- _pytest/fixtures.py | 10 +++++++++- _pytest/junitxml.py | 5 +++++ doc/en/reference.rst | 7 ++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/_pytest/fixtures.py b/_pytest/fixtures.py index 955a112b1..c4d5f726d 100644 --- a/_pytest/fixtures.py +++ b/_pytest/fixtures.py @@ -923,7 +923,15 @@ defaultfuncargprefixmarker = fixture() @fixture(scope="session") def pytestconfig(request): - """ the pytest config object with access to command line opts.""" + """Session-scoped fixture that returns the :class:`_pytest.config.Config` object. + + Example:: + + def test_foo(pytestconfig): + if pytestconfig.getoption("verbose"): + ... + + """ return request.config diff --git a/_pytest/junitxml.py b/_pytest/junitxml.py index e929eeba8..50f4e4084 100644 --- a/_pytest/junitxml.py +++ b/_pytest/junitxml.py @@ -200,6 +200,11 @@ def record_xml_property(request): """Add extra xml properties to the tag for the calling test. The fixture is callable with ``(name, value)``, with value being automatically xml-encoded. + + Example:: + + def test_function(record_xml_property): + record_xml_property("example_key", 1) """ request.node.warn( code='C3', diff --git a/doc/en/reference.rst b/doc/en/reference.rst index d00b20ddf..21ec13a43 100644 --- a/doc/en/reference.rst +++ b/doc/en/reference.rst @@ -416,5 +416,10 @@ The ``request`` fixture is a special fixture providing information of the reques pytestconfig ~~~~~~~~~~~~ -Scoped-session fixture which returns the internal :class:`_pytest.config.Config` object. +.. autofunction:: _pytest.fixtures.pytestconfig() + +record_xml_property +~~~~~~~~~~~~~~~~~~~ + +.. autofunction:: _pytest.junitxml.record_xml_property()