1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
|
--- a/junit_xml/__init__.py
+++ b/junit_xml/__init__.py
@@ -7,7 +7,6 @@
import xml.etree.ElementTree as ET
import xml.dom.minidom
-from six import u, iteritems, PY2
try:
# Python 2
@@ -59,18 +58,7 @@
"""
If not already unicode, decode it.
"""
- if PY2:
- if isinstance(var, unicode): # noqa: F821
- ret = var
- elif isinstance(var, str):
- if encoding:
- ret = var.decode(encoding)
- else:
- ret = unicode(var) # noqa: F821
- else:
- ret = unicode(var) # noqa: F821
- else:
- ret = str(var)
+ ret = str(var)
return ret
@@ -293,7 +281,7 @@
for key in ["time"]:
attributes[key] += float(ts_xml.get(key, 0))
xml_element.append(ts_xml)
- for key, value in iteritems(attributes):
+ for key, value in attributes.items():
xml_element.set(key, str(value))
xml_string = ET.tostring(xml_element, encoding=encoding)
@@ -357,7 +345,7 @@
illegal_ranges = ["%s-%s" % (unichr(low), unichr(high)) for (low, high) in illegal_unichrs if low < sys.maxunicode]
- illegal_xml_re = re.compile(u("[%s]") % u("").join(illegal_ranges))
+ illegal_xml_re = re.compile("[%s]" % "".join(illegal_ranges))
return illegal_xml_re.sub("", string_to_clean)
--- a/setup.py
+++ b/setup.py
@@ -28,5 +28,4 @@
"Topic :: Software Development :: Build Tools",
"Topic :: Software Development :: Testing",
],
- install_requires=["six"],
)
--- a/tests/serializer.py
+++ b/tests/serializer.py
@@ -3,8 +3,6 @@
import tempfile
from xml.dom import minidom
-from six import PY2
-
from junit_xml import to_xml_report_file, to_xml_report_string
@@ -26,8 +24,6 @@
os.remove(filename)
else:
xml_string = to_xml_report_string(test_suites, prettyprint=prettyprint, encoding=encoding)
- if PY2:
- assert isinstance(xml_string, unicode) # noqa: F821
print("Serialized XML to string:\n%s" % xml_string)
if encoding:
xml_string = xml_string.encode(encoding)
--- a/tests/test_test_case.py
+++ b/tests/test_test_case.py
@@ -1,7 +1,6 @@
# -*- coding: UTF-8 -*-
from __future__ import with_statement
-from six import u
from .asserts import verify_test_case
from junit_xml import TestCase as Case
@@ -188,19 +187,19 @@
def test_init_legal_unicode_char():
tc = Case("Failure-Message")
- tc.add_failure_info(u("failure message with legal unicode char: [\x22]"))
+ tc.add_failure_info("failure message with legal unicode char: [\x22]")
ts, tcs = serialize_and_read(Suite("test", [tc]))[0]
verify_test_case(
- tcs[0], {"name": "Failure-Message"}, failure_message=u("failure message with legal unicode char: [\x22]")
+ tcs[0], {"name": "Failure-Message"}, failure_message="failure message with legal unicode char: [\x22]"
)
def test_init_illegal_unicode_char():
tc = Case("Failure-Message")
- tc.add_failure_info(u("failure message with illegal unicode char: [\x02]"))
+ tc.add_failure_info("failure message with illegal unicode char: [\x02]")
ts, tcs = serialize_and_read(Suite("test", [tc]))[0]
verify_test_case(
- tcs[0], {"name": "Failure-Message"}, failure_message=u("failure message with illegal unicode char: []")
+ tcs[0], {"name": "Failure-Message"}, failure_message="failure message with illegal unicode char: []"
)
--- a/tests/test_test_suite.py
+++ b/tests/test_test_suite.py
@@ -5,7 +5,7 @@
import warnings
import pytest
-from six import PY2, StringIO
+from io import StringIO
from .asserts import verify_test_case
from junit_xml import TestCase as Case
@@ -197,8 +197,6 @@
Suite(name="suite2", test_cases=[Case(name="Test2")]),
]
xml_string = to_xml_report_string(test_suites)
- if PY2:
- assert isinstance(xml_string, unicode) # noqa: F821
expected_xml_string = textwrap.dedent(
"""
<?xml version="1.0" ?>
|