junitparser.junitparser module¶
junitparser is a JUnit/xUnit Result XML Parser. Use it to parse and manipulate existing Result XML files, or create new JUnit/xUnit result XMLs from scratch.
Reference schema: https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd
This, according to the document, is Apache Ant’s JUnit output.
See the documentation for other supported schemas.
- class junitparser.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.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.junitparser.Error(message: str = None, type_: str = None)[source]¶
Bases:
Result
Test result when the case has errors during execution.
- class junitparser.junitparser.Failure(message: str = None, type_: str = None)[source]¶
Bases:
Result
Test result when the case failed.
- class junitparser.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.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.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(filepath: str, parse_func=None)[source]¶
Initiate the object from a report file.
- classmethod fromroot(root_elem: Element)[source]¶
Construct JUnit objects from an elementTree root element.
- 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.junitparser.JUnitXmlError[source]¶
Bases:
Exception
Exception for JUnit XML related errors.
- class junitparser.junitparser.Properties[source]¶
Bases:
Element
A list of properties inside a testsuite.
See
Property
- class junitparser.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.junitparser.Result(message: str = None, type_: str = None)[source]¶
Bases:
Element
Base class for test result.
- message¶
Result as message string.
- type¶
Message type.
- message¶
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 text¶
- class junitparser.junitparser.Skipped(message: str = None, type_: str = None)[source]¶
Bases:
Result
Test result when the case is skipped.
- class junitparser.junitparser.System(content: str = None)[source]¶
Bases:
Element
Parent class for
SystemOut
andSystemErr
.- text¶
The output message.
- property text¶
- class junitparser.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.
- 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_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.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.
- junitparser.junitparser.attributed(cls)[source]¶
Decorator to read XML element attribute name from class attribute.