diff --git a/PKG-INFO b/PKG-INFO index 3d9e28080bc850ea37bf218e01b79432c0beeae7..19926f89ab8326a9f2fb63e93fc8bad5807bff15 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: junit-xml -Version: 1.6 +Version: 1.7 Summary: Creates JUnit XML test result documents that can be read by tools such as Jenkins Home-page: https://github.com/kyrus/python-junit-xml Author: Brian Beyer diff --git a/junit_xml.egg-info/PKG-INFO b/junit_xml.egg-info/PKG-INFO index 3d9e28080bc850ea37bf218e01b79432c0beeae7..19926f89ab8326a9f2fb63e93fc8bad5807bff15 100644 --- a/junit_xml.egg-info/PKG-INFO +++ b/junit_xml.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: junit-xml -Version: 1.6 +Version: 1.7 Summary: Creates JUnit XML test result documents that can be read by tools such as Jenkins Home-page: https://github.com/kyrus/python-junit-xml Author: Brian Beyer diff --git a/junit_xml/__init__.py b/junit_xml/__init__.py index 8e99bd6a971ee450ef8c8a6617631a13e670dd21..f969b4b29056304dc046831bcf2a776ef8d16fe2 100644 --- a/junit_xml/__init__.py +++ b/junit_xml/__init__.py @@ -55,9 +55,9 @@ Based on the understanding of what Jenkins can parse for JUnit XML files. def decode(var, encoding): - ''' + """ If not already unicode, decode it. - ''' + """ if PY2: if isinstance(var, unicode): ret = var @@ -74,9 +74,10 @@ def decode(var, encoding): class TestSuite(object): - '''Suite of test cases. + """ + Suite of test cases. Can handle unicode strings or binary strings if their encoding is provided. - ''' + """ def __init__(self, name, test_cases=None, hostname=None, id=None, package=None, timestamp=None, properties=None): @@ -94,14 +95,13 @@ class TestSuite(object): self.timestamp = timestamp self.properties = properties - def build_xml_doc(self, encoding=None): - ''' + """ Builds the XML document for the JUnit test suite. Produces clean unicode strings and decodes non-unicode with the help of encoding. @param encoding: Used to decode encoded strings. @return: XML document with unicode string elements - ''' + """ # build the test suite element test_suite_attributes = dict() @@ -192,10 +192,11 @@ class TestSuite(object): @staticmethod def to_xml_string(test_suites, prettyprint=True, encoding=None): - '''Returns the string representation of the JUnit XML document. + """ + Returns the string representation of the JUnit XML document. @param encoding: The encoding of the input. @return: unicode string - ''' + """ try: iter(test_suites) @@ -206,7 +207,7 @@ class TestSuite(object): attributes = defaultdict(int) for ts in test_suites: ts_xml = ts.build_xml_doc(encoding=encoding) - for key in ['failures', 'errors', 'skipped', 'tests']: + for key in ['failures', 'errors', 'tests']: attributes[key] += int(ts_xml.get(key, 0)) for key in ['time']: attributes[key] += float(ts_xml.get(key, 0)) @@ -233,22 +234,21 @@ class TestSuite(object): @staticmethod def to_file(file_descriptor, test_suites, prettyprint=True, encoding=None): - ''' + """ Writes the JUnit XML document to a file. - ''' + """ xml_string = TestSuite.to_xml_string( test_suites, prettyprint=prettyprint, encoding=encoding) # has problems with encoded str with non-ASCII (non-default-encoding) characters! file_descriptor.write(xml_string) - @staticmethod def _clean_illegal_xml_chars(string_to_clean): - ''' + """ Removes any illegal unicode characters from the given XML string. @see: http://stackoverflow.com/questions/1707890/fast-way-to-filter-illegal-xml-unicode-chars-in-python - ''' + """ illegal_unichrs = [ (0x00, 0x08), (0x0B, 0x1F), (0x7F, 0x84), (0x86, 0x9F), diff --git a/setup.py b/setup.py index 6e7134fe40b8a419524fa3b7ea14efc78591b780..c6df5af5bafeb105635d64a92ff8e9eb479ee9d8 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ setup( description='Creates JUnit XML test result documents that can be read by ' 'tools such as Jenkins', long_description=read('README.rst'), - version='1.6', + version='1.7', classifiers=[ 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', diff --git a/test_junit_xml.py b/test_junit_xml.py index d3c703e1e469d946bf3d31459d24fadedcc6779e..6956579410b782004c07e3bf9168a463f50a2c24 100644 --- a/test_junit_xml.py +++ b/test_junit_xml.py @@ -222,7 +222,7 @@ class TestSuiteTests(unittest.TestCase): self.assertTrue(isinstance(xml_string, unicode)) expected_xml_string = textwrap.dedent(""" <?xml version="1.0" ?> - <testsuites errors="0" failures="0" skipped="0" tests="2" time="0.0"> + <testsuites errors="0" failures="0" tests="2" time="0.0"> \t<testsuite errors="0" failures="0" name="suite1" skipped="0" tests="1" time="0"> \t\t<testcase name="Test1"/> \t</testsuite>