diff emeraldtree/tests/test_ElementTree.py @ 8:e1d0cd336bf3

Add testcases. emeraldtree/tests/test_ElementTree.py: Add testcases for Element.iter and Element.itertext.
author Bastian Blank <bblank@thinkmo.de>
date Sat, 31 May 2008 16:01:06 +0200
parents ced434b6bf72
children fc4b72233da0
line wrap: on
line diff
--- a/emeraldtree/tests/test_ElementTree.py	Sat May 31 15:56:42 2008 +0200
+++ b/emeraldtree/tests/test_ElementTree.py	Sat May 31 16:01:06 2008 +0200
@@ -16,11 +16,39 @@
     elem = Element('a')
     elem.append(Element('b'))
     assert serialize(elem) == '<a><b /></a>'
+
     elem.append(Element('c'))
     assert serialize(elem) == '<a><b /><c /></a>'
+
     elem.append('d')
     assert serialize(elem) == '<a><b /><c />d</a>'
 
+def test_Element_iter():
+    elem = Element('a')
+    l = list(elem.iter())
+    assert len(l) == 1
+
+    elem.append('b')
+    l = list(elem.iter())
+    assert len(l) == 1
+
+    elem.append(Element('c'))
+    l = list(elem.iter())
+    assert len(l) == 2
+
+    elem.append('d')
+    l = list(elem.iter())
+    assert len(l) == 2
+
+def test_Element_itertext():
+    elem = Element('a')
+    l = list(elem.itertext())
+    assert len(l) == 0
+
+    elem.append('b')
+    l = list(elem.itertext())
+    assert len(l) == 1
+
 def test_XMLParser_simple1():
     elem = XML('<a />')
     assert elem.tag == 'a'