Registry / testing / xunitparser

xunitparser

JSON →
library1.3.4pypypi✓ verified 84d ago

Read JUnit/XUnit XML files and map them to Python objects. Current version is 1.3.4, with infrequent releases.

pip install xunitparser
INSTALL
IMPORT
SIG · XUNITPARSER
X
xunitparser
testingpythonv1.3.4
Install
1.5s avg
Import
176ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.3.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.198s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.154s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parse
from xunitparser import parse
import xunitparser; ts, tr = xunitparser.parse(open('file.xml'))
Wrong: Using module-level function without importing explicitly leads to confusion. Correct: from xunitparser import parse
XmlTestSuite
from xunitparser import XmlTestSuite

Parse a JUnit XML file and print summary.

from xunitparser import parse import sys with open('test-results.xml') as f: ts, tr = parse(f) print(f'Testsuite: {ts.name}, tests: {ts.tests}, failures: {ts.failures}, errors: {ts.errors}') for tc in ts: print(f' Testcase: {tc.methodname} - {tc.result}')
Debug
Known issues
gotchaThe parse() function returns two values: (testsuite, testresult). The testresult object is often ignored but contains overall counts. Many users forget to unpack both.
fix
Always unpack both: ts, tr = parse(f) even if you don't use tr.
affects: all
gotchaThe library only handles JUnit XML format. Variants from pytest (--junitxml) or other runners may produce slightly different XML that fails to parse.
fix
Ensure the XML file is standard JUnit format. For pytest output, use 'pytest --junitxml=report.xml' and note that xunitparser handles it well.
affects: all
deprecatedThe library has not been updated since 2018. It uses ancient Python idioms and may not support Python 3.10+ fully (though it still works).
fix
Consider alternatives like junitparser or junit-xml if you need active maintenance.
affects: <1.3.4
Errors
Common errors & fixes
AttributeError: 'NoneType' object has no attribute 'name'
parse() returned None for testsuite when the XML could not be parsed, or the file was empty.
fix
Check that the XML file is valid and contains a <testsuite> element. Wrap parse in try-except.
TypeError: 'module' object is not callable
Using 'xunitparser.parse()' without importing the parse function correctly.
fix
Use: from xunitparser import parse
Upgrade
Version history
1.3.4latest on PyPI · released Feb 23, 2022
Audit
Dependencies

No dependency data recorded yet.

Agent activity
33 hits · last 30 days
node
30
OpenAI (training)
1
Resources
xunitparser — pip install xunitparser · libregistry