%define scl rh-python36 %{?scl:%scl_package %{name}} %{!?scl:%global pkg_name %{name}} %define name junit-xml %define version 1.8 %define unmangled_version 1.8 %define unmangled_version 1.8 %define release 1 Summary: Creates JUnit XML test result documents that can be read by tools such as Jenkins %{?scl:Requires: %{scl}-runtime} %{?scl:BuildRequires: %{scl}-runtime} Name: %{?scl_prefix}junit-xml Version: %{version} Release: %{release} Source0: junit-xml-%{unmangled_version}.tar.gz License: MIT Group: Development/Libraries BuildRoot: %{_tmppath}/junit-xml-%{version}-%{release}-buildroot Prefix: %{_prefix} BuildArch: noarch Vendor: Brian Beyer Packager: Martin Juhl Url: https://github.com/kyrus/python-junit-xml %description python-junit-xml ================ .. image:: 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. 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.* 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: .. code-block:: python 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 .. code-block:: xml I am stdout! I am stderr! Writing XML to a file: .. code-block:: python # 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 %prep %{?scl:scl enable %{scl} - << \EOF} set -ex %setup -n junit-xml-%{unmangled_version} -n junit-xml-%{unmangled_version} %{?scl:EOF} %build %{?scl:scl enable %{scl} - << \EOF} set -ex python3 setup.py build %{?scl:EOF} %install %{?scl:scl enable %{scl} - << \EOF} set -ex python3 setup.py install --single-version-externally-managed -O1 --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES %{?scl:EOF} %clean %{?scl:scl enable %{scl} - << \EOF} set -ex rm -rf $RPM_BUILD_ROOT %{?scl:EOF} %files -f INSTALLED_FILES %defattr(-,root,root)