diff emeraldtree/tests/test_ElementTree.py @ 27:4dc29d2eac0e

Force QName to be unicode. * emeraldtree/ElementTree.py: Convert all input for QName to unicode. * emeraldtree/tests/test_ElementTree.py: Check if members of QName are unicode.
author Bastian Blank <bblank@thinkmo.de>
date Thu, 12 Jun 2008 20:57:22 +0200
parents eeb0eb69c1da
children 96e02876b1a2
line wrap: on
line diff
--- a/emeraldtree/tests/test_ElementTree.py	Sun Jun 08 12:40:21 2008 +0200
+++ b/emeraldtree/tests/test_ElementTree.py	Thu Jun 12 20:57:22 2008 +0200
@@ -115,15 +115,17 @@
     elem = ProcessingInstruction('a', 'b')
     assert serialize(elem) == '<?a b?>'
 
-def test_QName():
+def test_QName___init__():
     qname = QName('a')
     assert qname.uri is None
     assert qname.name == 'a'
+    assert isinstance(qname.name, unicode)
     assert str(qname) == 'a'
     assert qname.text == 'a'
 
     qname = QName('{b}a')
     assert qname.uri == 'b'
+    assert isinstance(qname.uri, unicode)
     assert qname.name == 'a'
     assert str(qname) == '{b}a'
     assert qname.text == '{b}a'
@@ -137,6 +139,12 @@
     py.test.raises(ValueError, QName, '{ba')
     py.test.raises(ValueError, QName, '{b}a', 'c')
 
+def test_QName___cmp__():
+    qname1 = QName('a')
+    qname2 = QName('a')
+
+    assert cmp(qname1, qname2) == 0
+
 def test_XMLParser_simple1():
     elem = XML('<a />')
     assert elem.tag == 'a'