skip to navigation
skip to content

junit-xml 1.0

Creates JUnit XML test result documents that can be read by tools such as Jenkins

Latest Version: 1.6


A Python module for creating JUnit XML test result documents that can be read by tools such as Jenkins. If you are ever working with test tool or test suite written in Python and want to take advantage of Jenkins’ pretty graphs and test reporting capabilities, this module will let you generate the XML test reports.

As there is no definitive Jenkins JUnit XSD that I could find, the XML documents created by this module support a schema based on Google searches and the Jenkins JUnit XML reader source code. File a bug if something doesn’t work like you expect it to.


Clone the Git repository from Github and install it manually:

git clone
python install


Create a test suite, add a test case, and print it to the screen:

from junit_xml import TestSuite, TestCase

test_cases = [TestCase('Test1', '', 123.345, 'I am stdout!', 'I am stderr!')]
ts = TestSuite("my test suite", test_cases)
# pretty printing is on by default but can be disabled using prettyprint=False

Produces the following output

<?xml version="1.0" ?>
<testsuite errors="0" failures="0" name="my test suite" tests="1">
    <testcase classname="" name="Test1" time="123.345000">
            I am stdout!
            I am stderr!

Writing XML to a file:

# you can also write the XML to a file and not pretty print it
with open('output.xml') as f:
    ts.write_to_file(f, prettyprint=False)

See the docs and unit tests for more examples.

Running the tests

File Type Py Version Uploaded on Size
junit-xml-1.0.tar.gz (md5) Source 2013-01-17 5KB (md5) Source 2013-01-17 9KB
  • Downloads (All Versions):
  • 1434 downloads in the last day
  • 11742 downloads in the last week
  • 54926 downloads in the last month