view emeraldtree/tests/ @ 4:705fc192cd9d

Add new Node class and make it a base of Element. * emeraldtree/ - Add Node. - Make Node a base of Element. - Export Node. * emeraldtree/tests/ Update.
author Bastian Blank <>
date Sat, 31 May 2008 15:19:09 +0200
parents 40db0b033d47
children 9b72cb3ef3c9
line wrap: on
line source
from emeraldtree.ElementTree import *

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 />'
    assert isinstance(elem, Node)

def test_Element_append():
    elem = Element('a')
    assert serialize(elem) == '<a><b /></a>'
    assert serialize(elem) == '<a><b /><c /></a>'