junitparser package¶
Submodules¶
- junitparser.cli module
- junitparser.junitparser module
Attr
Element
Error
Failure
FinalResult
FloatAttr
IntAttr
JUnitXml
JUnitXml.name
JUnitXml.time
JUnitXml.tests
JUnitXml.failures
JUnitXml.errors
JUnitXml.skipped
JUnitXml.add_testsuite()
JUnitXml.errors
JUnitXml.failures
JUnitXml.fromfile()
JUnitXml.fromroot()
JUnitXml.fromstring()
JUnitXml.name
JUnitXml.skipped
JUnitXml.tests
JUnitXml.testsuite
JUnitXml.time
JUnitXml.update_statistics()
JUnitXml.write()
JUnitXmlError
Properties
Property
Result
Skipped
System
SystemErr
SystemOut
TestCase
TestSuite
TestSuite.name
TestSuite.hostname
TestSuite.time
TestSuite.timestamp
TestSuite.tests
TestSuite.failures
TestSuite.errors
TestSuite.skipped
TestSuite.add_property()
TestSuite.add_testcase()
TestSuite.add_testcases()
TestSuite.add_testsuite()
TestSuite.errors
TestSuite.failures
TestSuite.hostname
TestSuite.name
TestSuite.properties()
TestSuite.remove_property()
TestSuite.remove_testcase()
TestSuite.skipped
TestSuite.testcase
TestSuite.tests
TestSuite.testsuites()
TestSuite.time
TestSuite.timestamp
TestSuite.update_statistics()
TestSuite.write()
attributed()
junitxml
write_xml()
- junitparser.xunit2 module
Module contents¶
- class junitparser.Attr(name: str = None)[source]¶
Bases:
object
An attribute for an XML element.
By default they are all string values. To support different value types, inherit this class and define your own methods.
- class junitparser.Element(name: str = None)[source]¶
Bases:
object
Base class for all JUnit XML elements.
- append(sub_elem)[source]¶
Add the element subelement to the end of this elements internal list of subelements.
- class junitparser.Error(message: str = None, type_: str = None)[source]¶
Bases:
FinalResult
Test result when the case has errors during execution.
- class junitparser.Failure(message: str = None, type_: str = None)[source]¶
Bases:
FinalResult
Test result when the case failed.
- class junitparser.FloatAttr(name: str = None)[source]¶
Bases:
Attr
A float attribute for an XML element.
This class is used internally for counting test durations, but you could use it for any specific purpose.
- class junitparser.IntAttr(name: str = None)[source]¶
Bases:
Attr
An integer attribute for an XML element.
This class is used internally for counting testcases, but you could use it for any specific purpose.
- class junitparser.JUnitXml(name=None)[source]¶
Bases:
Element
The JUnitXml root object.
It may contain
<TestSuites>
or a<TestSuite>
.- name¶
Name of the testsuite if it only contains one testsuite.
- time¶
Time consumed by the testsuites.
- tests¶
Total number of tests.
- failures¶
Number of failed cases.
- errors¶
Number of cases with errors.
- skipped¶
Number of skipped cases.
- errors¶
An integer attribute for an XML element.
This class is used internally for counting testcases, but you could use it for any specific purpose.
- failures¶
An integer attribute for an XML element.
This class is used internally for counting testcases, but you could use it for any specific purpose.
- classmethod fromfile(file: str | IO, parse_func=None)[source]¶
Construct JUnit objects from an XML file.
The
file
can be any of the following:a file name/path
a file object
a file-like object
a URL using the HTTP or FTP protocol (with lxml only)
- classmethod fromroot(root_elem: Element)[source]¶
Construct JUnit objects from an elementTree root element.
- classmethod fromstring(text: str | bytes)[source]¶
Construct JUnit objects from an XML string (str or bytes).
- name¶
An attribute for an XML element.
By default they are all string values. To support different value types, inherit this class and define your own methods.
- skipped¶
An integer attribute for an XML element.
This class is used internally for counting testcases, but you could use it for any specific purpose.
- tests¶
An integer attribute for an XML element.
This class is used internally for counting testcases, but you could use it for any specific purpose.
- time¶
A float attribute for an XML element.
This class is used internally for counting test durations, but you could use it for any specific purpose.
- exception junitparser.JUnitXmlError[source]¶
Bases:
Exception
Exception for JUnit XML related errors.
- class junitparser.Properties[source]¶
Bases:
Element
A list of properties inside a testsuite.
See
Property
- class junitparser.Property(name: str = None, value: str = None)[source]¶
Bases:
Element
A key/value pare that’s stored in the testsuite.
Use it to store anything you find interesting or useful.
- name¶
The property name.
- value¶
The property value.
- name¶
An attribute for an XML element.
By default they are all string values. To support different value types, inherit this class and define your own methods.
- class junitparser.Skipped(message: str = None, type_: str = None)[source]¶
Bases:
FinalResult
Test result when the case is skipped.
- class junitparser.TestCase(name: str = None, classname: str = None, time: float = None)[source]¶
Bases:
Element
Object to store a testcase and its result.
- name¶
Name of the testcase.
- classname¶
The parent class of the testcase.
- time¶
The time consumed by the testcase.
- ITER_TYPES = {'error': <class 'junitparser.junitparser.Error'>, 'failure': <class 'junitparser.junitparser.Failure'>, 'skipped': <class 'junitparser.junitparser.Skipped'>, 'system-err': <class 'junitparser.junitparser.SystemErr'>, 'system-out': <class 'junitparser.junitparser.SystemOut'>}¶
- classname¶
An attribute for an XML element.
By default they are all string values. To support different value types, inherit this class and define your own methods.
- property is_error¶
Whether this testcase errored.
- property is_failure¶
Whether this testcase failed.
- property is_passed¶
Whether this testcase was a success (i.e. if it isn’t skipped, failed, or errored).
- property is_skipped¶
Whether this testcase was skipped.
- name¶
An attribute for an XML element.
By default they are all string values. To support different value types, inherit this class and define your own methods.
- property system_err¶
stderr.
- property system_out¶
stdout.
- time¶
A float attribute for an XML element.
This class is used internally for counting test durations, but you could use it for any specific purpose.
- class junitparser.TestSuite(name=None)[source]¶
Bases:
Element
The <testsuite> object.
- name¶
The name of the testsuite.
- hostname¶
Name of the test machine.
- time¶
Time consumed by the testsuite.
- timestamp¶
When the test was run.
- tests¶
Total number of tests.
- failures¶
Number of failed tests.
- errors¶
Number of cases with errors.
- skipped¶
Number of skipped cases.
- add_property(name: str, value: str)[source]¶
Add a property name = value to the testsuite.
See
Property
andProperties
.
- errors¶
An integer attribute for an XML element.
This class is used internally for counting testcases, but you could use it for any specific purpose.
- failures¶
An integer attribute for an XML element.
This class is used internally for counting testcases, but you could use it for any specific purpose.
- hostname¶
An attribute for an XML element.
By default they are all string values. To support different value types, inherit this class and define your own methods.
- name¶
An attribute for an XML element.
By default they are all string values. To support different value types, inherit this class and define your own methods.
- skipped¶
An integer attribute for an XML element.
This class is used internally for counting testcases, but you could use it for any specific purpose.
- tests¶
An integer attribute for an XML element.
This class is used internally for counting testcases, but you could use it for any specific purpose.
- time¶
A float attribute for an XML element.
This class is used internally for counting test durations, but you could use it for any specific purpose.
- timestamp¶
An attribute for an XML element.
By default they are all string values. To support different value types, inherit this class and define your own methods.