From 320bdda6e979e340fe159f3565b0f6fd977f9022 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Sun, 6 Dec 2015 21:20:05 +0100 Subject: [PATCH] Unittests: Run python-modernize --- testcss.py | 4 ++++ testscour.py | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/testcss.py b/testcss.py index 70601e0..a46144e 100755 --- a/testcss.py +++ b/testcss.py @@ -19,9 +19,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import absolute_import + import unittest + from scour.yocto_css import parseCssString + class Blank(unittest.TestCase): def runTest(self): r = parseCssString('') diff --git a/testscour.py b/testscour.py index 9f7a5b3..4fbdef3 100755 --- a/testscour.py +++ b/testscour.py @@ -20,11 +20,18 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import absolute_import + +import six +from six.moves import map, range + import unittest import xml.dom.minidom + from scour.svg_regex import svg_parser from scour.scour import scourXmlFile, scourString, parse_args, makeWellFormed + SVGNS = 'http://www.w3.org/2000/svg' # I couldn't figure out how to get ElementTree to work with the following XPath @@ -591,7 +598,7 @@ class ChangeQuadToShorthandInPath(unittest.TestCase): class HandleNonAsciiUtf8(unittest.TestCase): def runTest(self): doc = scour.scourXmlFile('unittests/utf8.svg') - desc = unicode(doc.getElementsByTagNameNS(SVGNS, 'desc')[0].firstChild.wholeText).strip() + desc = six.text_type(doc.getElementsByTagNameNS(SVGNS, 'desc')[0].firstChild.wholeText).strip() self.assertEquals( desc, u'รบ', 'Did not handle non-ASCII characters' ) @@ -1066,7 +1073,7 @@ class RemoveMetadataOption(unittest.TestCase): class EnableCommentStrippingOption(unittest.TestCase): def runTest(self): - docStr = file('unittests/comment-beside-xml-decl.svg').read() + docStr = open('unittests/comment-beside-xml-decl.svg').read() docStr = scour.scourString(docStr, scour.parse_args(['--enable-comment-stripping'])[0]) self.assertEquals(docStr.find('