_pytest.junitxml module¶
Based on initial code from Ross Lawley.
Output conforms to https://github.com/jenkinsci/xunit-plugin/blob/master/ src/main/resources/org/jenkinsci/plugins/xunit/types/model/xsd/junit-10.xsd
-
_warn_incompatibility_with_xunit2
(request, fixture_name)[source]¶ Emits a PytestWarning about the given fixture being incompatible with newer xunit revisions
-
record_property
(request)[source]¶ Add an extra properties the calling test. User properties become part of the test report and are available to the configured reporters, like JUnit XML. The fixture is callable with
(name, value)
, with value being automatically xml-encoded.Example:
def test_function(record_property): record_property("example_key", 1)
-
record_xml_attribute
(request)[source]¶ Add extra xml attributes to the tag for the calling test. The fixture is callable with
(name, value)
, with value being automatically xml-encoded
-
_check_record_param_type
(param, v)[source]¶ Used by record_testsuite_property to check that the given parameter name is of the proper type
-
record_testsuite_property
(request)[source]¶ Records 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 withxunit2
JUnit family.This is a
session
-scoped fixture which is called with(name, value)
. Example:def test_foo(record_testsuite_property): record_testsuite_property("ARCH", "PPC") record_testsuite_property("STORAGE_TYPE", "CEPH")
name
must be a string,value
will be converted to a string and properly xml-escaped.
-
class
LogXML
(logfile, prefix, suite_name='pytest', logging='no', report_duration='total', family='xunit1', log_passing_tests=True)[source]¶ Bases:
object
-
pytest_runtest_logreport
(report)[source]¶ handle a setup/call/teardown report, generating the appropriate xml tags as necessary.
note: due to plugins like xdist, this hook may be called in interlaced order with reports from other nodes. for example:
- usual call order:
-> setup node1 -> call node1 -> teardown node1 -> setup node2 -> call node2 -> teardown node2
- possible call order in xdist:
-> setup node1 -> call node1 -> setup node2 -> call node2 -> teardown node2 -> teardown node1
-