Skip to content

Commit 5648005

Browse files
authored
implement flavors (#108)
1 parent cbf4271 commit 5648005

10 files changed

+776
-432
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [3.1.0] - 2023-04-22
4+
### Added
5+
- Support for different schemas.
6+
- xunit2 flavor support
7+
- Type hints
8+
39
## [3.0.0] - 2023-04-20
410
### Breaking
511
Python 2 is no longer supported. Version 2.x will keep supporting py2 and it will be maintained as long as possible, though no new features will be added.

README.rst

+33
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,39 @@ You have two or more XML files, and you want to merge them into one.
129129
Note that it won't check for duplicate entries. You need to deal with them on
130130
your own.
131131

132+
Schema Support
133+
~~~~~~~~~~~~~~~
134+
135+
By default junitparser supports the schema of windyroad_, which is a relatively
136+
simple schema.
137+
138+
.. _windyroad: https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd
139+
140+
Junitparser also support extra schemas:
141+
142+
.. code-block:: python
143+
144+
from junitparser.xunit2 import JUnitParser, TestCase, TestSuite, \
145+
RerunFailure
146+
# These classes are redefined to support extra properties and attributes
147+
# of the xunit2 schema.
148+
suite = TestSuite("mySuite")
149+
suite.system_err = "System err" # xunit2 specific property
150+
case = TestCase("myCase")
151+
rerun_failure = RerunFailure("Not found", "404") # case property
152+
rerun_failure.stack_trace = "Stack"
153+
rerun_failure.system_err = "E404"
154+
rerun_failure.system_out = "NOT FOUND"
155+
case.add_rerun_result(rerun_failure)
156+
157+
Currently supported schemas including:
158+
159+
- xunit2_, supported by pytest, Erlang/OTP, Maven Surefire, CppTest, etc.
160+
161+
.. _xunit2: https://github.com/jenkinsci/xunit-plugin/blob/xunit-2.3.2/src/main/resources/org/jenkinsci/plugins/xunit/types/model/xsd/junit-10.xsd
162+
163+
PRs are welcome to support more schemas.
164+
132165
Create XML with custom attributes
133166
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
134167

junitparser/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
FloatAttr,
1515
)
1616

17-
version = "3.0.0"
17+
version = "3.1.0"

junitparser/cli.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ def _parser(prog_name=None): # pragma: no cover
6565

6666
# command: verify
6767
merge_parser = command_parser.add_parser(
68-
"verify", help="Return a non-zero exit code if one of the testcases failed or errored."
68+
"verify",
69+
help="Return a non-zero exit code if one of the testcases failed or errored.",
6970
)
7071
merge_parser.add_argument(
7172
"--glob",
@@ -74,7 +75,9 @@ def _parser(prog_name=None): # pragma: no cover
7475
action="store_true",
7576
default=False,
7677
)
77-
merge_parser.add_argument("paths", nargs="+", help="XML path(s) of reports to verify.")
78+
merge_parser.add_argument(
79+
"paths", nargs="+", help="XML path(s) of reports to verify."
80+
)
7881

7982
return parser
8083

0 commit comments

Comments
 (0)