changeset 6:ced434b6bf72

Add testcases. emeraldtree/tests/test_ElementTree.py: Add testcases for XMLParser.
author Bastian Blank <bblank@thinkmo.de>
date Sat, 31 May 2008 15:46:29 +0200
parents 9b72cb3ef3c9
children a30d65781076
files emeraldtree/tests/test_ElementTree.py
diffstat 1 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/emeraldtree/tests/test_ElementTree.py	Sat May 31 15:40:43 2008 +0200
+++ b/emeraldtree/tests/test_ElementTree.py	Sat May 31 15:46:29 2008 +0200
@@ -20,3 +20,28 @@
     assert serialize(elem) == '<a><b /><c /></a>'
     elem.append('d')
     assert serialize(elem) == '<a><b /><c />d</a>'
+
+def test_XMLParser_simple1():
+    elem = XML('<a />')
+    assert elem.tag == 'a'
+    assert len(elem) == 0
+
+def test_XMLParser_simple2():
+    elem = XML('<a><b /></a>')
+    assert elem.tag == 'a'
+    assert len(elem) == 1
+    assert elem[0].tag == 'b'
+    assert len(elem[0]) == 0
+
+def test_XMLParser_text1():
+    elem = XML('<a>b</a>')
+    assert elem.tag == 'a'
+    assert len(elem) == 1
+
+def test_XMLParser_text2():
+    elem = XML('<a>b<c>d</c>d</a>')
+    assert elem.tag == 'a'
+    assert len(elem) == 3
+    assert elem[0] == 'b'
+    assert elem[1].tag == 'c'
+    assert elem[2] == 'd'