junit-xml


Namejunit-xml JSON
Version 1.9 PyPI version JSON
download
home_pagehttps://github.com/kyrus/python-junit-xml
SummaryCreates JUnit XML test result documents that can be read by tools such as Jenkins
upload_time2023-01-24 18:42:00
maintainer
docs_urlNone
authorBrian Beyer
requires_python
licenseMIT
keywords
VCS
bugtrack_url
requirements six
Travis-CI
coveralls test coverage No coveralls.
            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 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:

.. 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

    <?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:

.. 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




            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/kyrus/python-junit-xml",
    "name": "junit-xml",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Brian Beyer",
    "author_email": "brian@kyr.us",
    "download_url": "https://files.pythonhosted.org/packages/98/af/bc988c914dd1ea2bc7540ecc6a0265c2b6faccc6d9cdb82f20e2094a8229/junit-xml-1.9.tar.gz",
    "platform": "",
    "description": "python-junit-xml\n================\n.. image:: https://travis-ci.org/kyrus/python-junit-xml.png?branch=master\n\nAbout\n-----\n\nA Python module for creating JUnit XML test result documents that can be\nread by tools such as Jenkins or Bamboo. If you are ever working with test tool or\ntest suite written in Python and want to take advantage of Jenkins' or Bamboo's\npretty graphs and test reporting capabilities, this module will let you\ngenerate the XML test reports.\n\n*As there is no definitive Jenkins JUnit XSD that I could find, the XML\ndocuments created by this module support a schema based on Google\nsearches and the Jenkins JUnit XML reader source code. File a bug if\nsomething doesn't work like you expect it to.\nFor Bamboo situation is the same.*\n\nInstallation\n------------\n\nInstall using pip or easy_install:\n\n::\n\n\tpip install junit-xml\n\tor\n\teasy_install junit-xml\n\nYou can also clone the Git repository from Github and install it manually:\n\n::\n\n    git clone https://github.com/kyrus/python-junit-xml.git\n    python setup.py install\n\nUsing\n-----\n\nCreate a test suite, add a test case, and print it to the screen:\n\n.. code-block:: python\n\n    from junit_xml import TestSuite, TestCase\n\n    test_cases = [TestCase('Test1', 'some.class.name', 123.345, 'I am stdout!', 'I am stderr!')]\n    ts = TestSuite(\"my test suite\", test_cases)\n    # pretty printing is on by default but can be disabled using prettyprint=False\n    print(TestSuite.to_xml_string([ts]))\n\nProduces the following output\n\n.. code-block:: xml\n\n    <?xml version=\"1.0\" ?>\n    <testsuites>\n        <testsuite errors=\"0\" failures=\"0\" name=\"my test suite\" tests=\"1\">\n            <testcase classname=\"some.class.name\" name=\"Test1\" time=\"123.345000\">\n                <system-out>\n                    I am stdout!\n                </system-out>\n                <system-err>\n                    I am stderr!\n                </system-err>\n            </testcase>\n        </testsuite>\n    </testsuites>\n\nWriting XML to a file:\n\n.. code-block:: python\n\n    # you can also write the XML to a file and not pretty print it\n    with open('output.xml', 'w') as f:\n        TestSuite.to_file(f, [ts], prettyprint=False)\n\nSee the docs and unit tests for more examples.\n\nNOTE: Unicode characters identified as \"illegal or discouraged\" are automatically\nstripped from the XML string or file.\n\nRunning the tests\n-----------------\n\n::\n\n    # activate your virtualenv\n    pip install tox\n    tox\n\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Creates JUnit XML test result documents that can be read by tools such as Jenkins",
    "version": "1.9",
    "project_urls": {
        "Homepage": "https://github.com/kyrus/python-junit-xml"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2a932d896b5fd3d79b4cadd8882c06650e66d003f465c9d12c488d92853dff78",
                "md5": "dcb66da4f3905756ddb2432b0a7cdbdc",
                "sha256": "ec5ca1a55aefdd76d28fcc0b135251d156c7106fa979686a4b48d62b761b4732"
            },
            "downloads": -1,
            "filename": "junit_xml-1.9-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "dcb66da4f3905756ddb2432b0a7cdbdc",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 7130,
            "upload_time": "2020-02-22T20:41:37",
            "upload_time_iso_8601": "2020-02-22T20:41:37.661860Z",
            "url": "https://files.pythonhosted.org/packages/2a/93/2d896b5fd3d79b4cadd8882c06650e66d003f465c9d12c488d92853dff78/junit_xml-1.9-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "98afbc988c914dd1ea2bc7540ecc6a0265c2b6faccc6d9cdb82f20e2094a8229",
                "md5": "a21d0456f5e44c7baedb029e174e8e42",
                "sha256": "de16a051990d4e25a3982b2dd9e89d671067548718866416faec14d9de56db9f"
            },
            "downloads": -1,
            "filename": "junit-xml-1.9.tar.gz",
            "has_sig": false,
            "md5_digest": "a21d0456f5e44c7baedb029e174e8e42",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 7349,
            "upload_time": "2023-01-24T18:42:00",
            "upload_time_iso_8601": "2023-01-24T18:42:00.836931Z",
            "url": "https://files.pythonhosted.org/packages/98/af/bc988c914dd1ea2bc7540ecc6a0265c2b6faccc6d9cdb82f20e2094a8229/junit-xml-1.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-24 18:42:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "kyrus",
    "github_project": "python-junit-xml",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "six",
            "specs": []
        }
    ],
    "tox": true,
    "lcname": "junit-xml"
}
        
Elapsed time: 0.40780s