diff emeraldtree/tests/test_ElementTree.py @ 3:40db0b033d47

Add testcases. * emeraldtree/tests/__init__.py: Add. * emeraldtree/tests/test_ElementTree.py: Add testcases.
author Bastian Blank <bblank@thinkmo.de>
date Sat, 31 May 2008 15:10:47 +0200
parents
children 705fc192cd9d
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/emeraldtree/tests/test_ElementTree.py	Sat May 31 15:10:47 2008 +0200
@@ -0,0 +1,19 @@
+from emeraldtree.ElementTree import ElementTree, Element
+
+def serialize(elem, **options):
+    from cStringIO import StringIO
+    file = StringIO()
+    tree = ElementTree(elem)
+    tree.write(file, **options)
+    return file.getvalue()
+
+def test_Element___init__():
+    elem = Element('a')
+    assert serialize(elem) == '<a />'
+
+def test_Element_append():
+    elem = Element('a')
+    elem.append(Element('b'))
+    assert serialize(elem) == '<a><b /></a>'
+    elem.append(Element('c'))
+    assert serialize(elem) == '<a><b /><c /></a>'