Commits

Graham Higgins committed ea3a786

Neatening up.

Comments (0)

Files changed (5)

 import sys
-PY3 = True if sys.version_info[:1] == (3,) else False
+PY3 = (sys.version_info[0] >= 3)
 try:
     from io import StringIO
 except ImportError:

strainer/operators.py

         if v1 == '&ignore' or v2 == '&ignore':
             log.info('Ignored comparison for key: %s', key)
             continue
-        if not isinstance(v2, str) and isinstance(v1, str):
+        if not isinstance(v2, six.text_type) and isinstance(v1, six.text_type):
             if not eq_pprint(type(v1), type(v2)):
                 log.error(
                     'The types of values for "%s" do not match (%s vs. %s)' %
 
 
 def eq_json(a, b):
-    if isinstance(a, str):
+    if isinstance(a, six.text_type):
         a = loads(a)
-    if isinstance(b, str):
+    if isinstance(b, six.text_type):
         b = loads(b)
 
     return eq_dict(a, b)

strainer/xhtmlify.py

     encodingdecl = ''
     if encoding is not None:
         EncName_re = re.compile(r'[A-Za-z][A-Za-z0-9._-]*\Z')  # from XML spec
-        if isinstance(encoding, str) and EncName_re.match(encoding):
+        if isinstance(encoding, six.text_type) and EncName_re.match(encoding):
             encodingdecl = ' encoding="%s"' % encoding
         else:
             # Don't tell them expected format, guessing won't help

tests/test_case.py

 from __future__ import print_function
-import sys
-PY3 = True if sys.version_info[:1] == (3,) else False
+from strainer.case import call_super, STestCase, DelayedException
+from strainer.xhtmlify import PY3
+from nose.tools import eq_, raises
 
-from strainer.case import call_super, STestCase, DelayedException
-from nose.tools import eq_, raises
 
 class FooTest(STestCase):
     def setUp(self):

tests/test_xhtmlify.py

 import re
 import encodings.aliases
 import codecs
-import sys
-PY3 = True if sys.version_info[:1] == (3,) else False
 from strainer.xhtmlify import xhtmlify as _xhtmlify, xmlparse, ValidationError
 from strainer.xhtmlify import sniff_encoding, fix_xmldecl
 from strainer.doctypes import DOCTYPE_XHTML1_STRICT