diff emeraldtree/tests/test_tree.py @ 100:9d39d4bc2deb

ported to python 2.7 / >= 3.3 using six the port itself was half automated (using python-modernize) and half manual fixes and cleanups.
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 19 May 2013 20:37:50 +0200
parents f7db63ba09f4
children 310ef85ca282
line wrap: on
line diff
--- a/emeraldtree/tests/test_tree.py	Sun Dec 23 19:39:04 2012 +0100
+++ b/emeraldtree/tests/test_tree.py	Sun May 19 20:37:50 2013 +0200
@@ -1,8 +1,9 @@
 import py.test
 from emeraldtree.tree import *
+import six
+from six import StringIO
 
 def serialize(elem, namespaces={}):
-    from StringIO import StringIO
     file = StringIO()
     elem.write(file.write, namespaces=namespaces)
     return file.getvalue()
@@ -343,19 +344,19 @@
     qname = QName(u'a')
     assert qname.uri is None
     assert qname.name == u'a'
-    assert isinstance(qname.name, unicode)
-    assert unicode(qname) == u'a'
+    assert isinstance(qname.name, six.text_type)
+    assert six.text_type(qname) == u'a'
 
     qname = QName(u'{b}a')
     assert qname.uri == u'b'
-    assert isinstance(qname.uri, unicode)
+    assert isinstance(qname.uri, six.text_type)
     assert qname.name == u'a'
-    assert unicode(qname) == u'{b}a'
+    assert six.text_type(qname) == u'{b}a'
 
     qname = QName(u'a', u'b')
     assert qname.uri == u'b'
     assert qname.name == u'a'
-    assert unicode(qname) == u'{b}a'
+    assert six.text_type(qname) == u'{b}a'
 
     py.test.raises(ValueError, QName, u'{bau')
     py.test.raises(ValueError, QName, u'{b}a', u'c')
@@ -393,7 +394,7 @@
     assert isinstance(elem, Element)
     assert len(elem) == 1
     assert elem[0] == u'b'
-    assert isinstance(elem[0], unicode)
+    assert isinstance(elem[0], six.text_type)
 
 def test_XMLParser_text2():
     elem = XML(u'<a>b<c>d</c>d</a>')