Skip to main content
File added late

1 file was added to this release more than 14 days after its initial publication. Inspect the release files before installing.

https://travis-ci.org/kyrus/python-junit-xml.png?branch=master

About

A Python module for creating JUnit XML test result documents that can be read by tools such as Jenkins or Bamboo. If you are ever working with test tool or test suite written in Python and want to take advantage of Jenkins’ or Bamboo’s 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. For Bamboo situation is the same.

Installation

Install using pip or easy_install:

pip install junit-xml
or
easy_install junit-xml

You can also clone the Git repository from Github and install it manually:

git clone https://github.com/kyrus/python-junit-xml.git
python setup.py install

Using

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

from junit_xml import TestSuite, TestCase

test_cases = [TestCase('Test1', 'some.class.name', 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
print(TestSuite.to_xml_string([ts]))

Produces the following output

<?xml version="1.0" ?>
<testsuites>
    <testsuite errors="0" failures="0" name="my test suite" tests="1">
        <testcase classname="some.class.name" name="Test1" time="123.345000">
            <system-out>
                I am stdout!
            </system-out>
            <system-err>
                I am stderr!
            </system-err>
        </testcase>
    </testsuite>
</testsuites>

Writing XML to a file:

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

See the docs and unit tests for more examples.

NOTE: Unicode characters identified as “illegal or discouraged” are automatically stripped from the XML string or file.

Running the tests

# activate your virtualenv
pip install tox
tox

Release files for junit-xml 1.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

File added late

1 file was uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.

We recommend inspecting the release files before installing.

Source distribution (sdist)

Source distribution for junit-xml 1.9
File Size Uploaded
junit-xml-1.9.tar.gz 7.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for junit-xml 1.9
File Interpreter ABI Platform
junit_xml-1.9-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 14.5 kB

Release files / junit-xml-1.9.tar.gz

File added late

This file was uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.

We recommend inspecting the release file before installing.

Download URL junit-xml-1.9.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
de16a051990d4e25a3982b2dd9e89d671067548718866416faec14d9de56db9f
BLAKE2b-256 checksum
How to use checksums
98afbc988c914dd1ea2bc7540ecc6a0265c2b6faccc6d9cdb82f20e2094a8229
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / junit_xml-1.9-py2.py3-none-any.whl

Download URL junit_xml-1.9-py2.py3-none-any.whl
Size 7.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
ec5ca1a55aefdd76d28fcc0b135251d156c7106fa979686a4b48d62b761b4732
BLAKE2b-256 checksum
How to use checksums
2a932d896b5fd3d79b4cadd8882c06650e66d003f465c9d12c488d92853dff78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/2.7.16

Release history Release notifications | RSS feed

This release

1.9 This release

2 release files

1.8

1 release file

1.7

1 release file

1.6

1 release file

1.5

1 release file

1.4

1 release file

1.3

1 release file

1.2

1 release file

1.1

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page