Improve pytestconfig and add record_xml_property

This commit is contained in:
Bruno Oliveira 2018-02-27 17:19:57 -03:00
parent 7ba8a4ee75
commit 111c6d6a22
3 changed files with 20 additions and 2 deletions

View File

@ -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

View File

@ -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',

View File

@ -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()