view 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 source
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>'