diff emeraldtree/tests/test_ElementTree.py @ 40:a8382b8cded5

Testcases for ElementTree - Check all variants of namespace attributes
author Bastian Blank <bblank@thinkmo.de>
date Thu, 24 Jul 2008 08:32:31 +0200
parents 6e38bcef6030
children 78ef2b77ca4a
line wrap: on
line diff
--- a/emeraldtree/tests/test_ElementTree.py	Mon Jul 21 12:43:20 2008 +0200
+++ b/emeraldtree/tests/test_ElementTree.py	Thu Jul 24 08:32:31 2008 +0200
@@ -256,18 +256,18 @@
     assert elem[2] == 'd'
 
 def test_XMLParser_namespace():
-    elem = XML('<a:b xmlns:a="c"/>')
+    elem = XML('<b xmlns="c" d="e"/>')
     assert isinstance(elem.tag, QName)
     assert elem.tag == QName('b', 'c')
-    assert serialize(elem) == '<ns0:b xmlns:ns0="c" />'
-
-    elem = XML('<a:b xmlns:a="c" d="e"/>')
-    assert elem.tag == QName('b', 'c')
-    assert elem.attrib == {'d': 'e'}
+    assert elem.attrib == {QName('d', None): 'e'}
     assert serialize(elem) == '<ns0:b d="e" xmlns:ns0="c" />'
+    assert serialize(elem, default_namespace='c') == '<ns0:b d="e" xmlns:ns0="c" />'
 
-    elem = XML('<a:b xmlns:a="c" a:d="e"/>')
+    elem = XML('<a:b xmlns:a="c" d="e" a:f="g"/>')
+    assert isinstance(elem.tag, QName)
     assert elem.tag == QName('b', 'c')
-    assert elem.attrib == {QName('d', 'c'): 'e'}
-    assert serialize(elem) == '<ns0:b ns0:d="e" xmlns:ns0="c" />'
+    assert elem.attrib == {'d': 'e', QName('f', 'c'): 'g'}
+    assert serialize(elem) == '<ns0:b d="e" ns0:f="g" xmlns:ns0="c" />'
+    assert serialize(elem, default_namespace='c') == '<ns0:b d="e" ns0:f="g" xmlns:ns0="c" />'
 
+