diff emeraldtree/tests/test_ElementTree.py @ 16:533331338691

Use parsed values of QName in namespace lookup. * emeraldtree/ElementTree.py - Use parsed QName in namespace lookup. - Remove support for QNames as values. * emeraldtree/tests/test_ElementTree.py: Add testcases.
author Bastian Blank <bblank@thinkmo.de>
date Sat, 31 May 2008 18:21:41 +0200
parents 60f59340b897
children 42e1c75e8bcb
line wrap: on
line diff
--- a/emeraldtree/tests/test_ElementTree.py	Sat May 31 17:46:46 2008 +0200
+++ b/emeraldtree/tests/test_ElementTree.py	Sat May 31 18:21:41 2008 +0200
@@ -109,3 +109,19 @@
     assert elem[0] == 'b'
     assert elem[1].tag == 'c'
     assert elem[2] == 'd'
+
+def test_XMLParser_namespace():
+    elem = XML('<a:a xmlns:a="a"/>')
+    assert elem.tag == QName('a', 'a')
+    assert serialize(elem) == '<ns0:a xmlns:ns0="a" />'
+
+    elem = XML('<a:a xmlns:a="a" a="a"/>')
+    assert elem.tag == QName('a', 'a')
+    assert elem.attrib == {'a': 'a'}
+    assert serialize(elem) == '<ns0:a a="a" xmlns:ns0="a" />'
+
+    elem = XML('<a:a xmlns:a="a" a:a="a"/>')
+    assert elem.tag == QName('a', 'a')
+    assert elem.attrib == {QName('a', 'a'): 'a'}
+    assert serialize(elem) == '<ns0:a ns0:a="a" xmlns:ns0="a" />'
+