diff emeraldtree/tests/test_html.py @ 73:641657361783

Tests for HTML support - Fix invocation, add tests for ouput
author Bastian Blank <bblank@thinkmo.de>
date Fri, 04 Jun 2010 13:02:19 +0200
parents d7e235461c97
children 223789ea05b2
line wrap: on
line diff
--- a/emeraldtree/tests/test_html.py	Fri Jun 04 12:58:21 2010 +0200
+++ b/emeraldtree/tests/test_html.py	Fri Jun 04 13:02:19 2010 +0200
@@ -2,26 +2,25 @@
 
 from .. import html, tree
 
-def serialize(elem, **options):
-    from cStringIO import StringIO
+def serialize(elem):
+    from StringIO import StringIO
     file = StringIO()
-    tree = ElementTree(elem)
-    tree.write(file, **options)
+    elem.write(file.write, method='html')
     return file.getvalue()
 
-def test_HTMLParser_simple1():
+def test_read_simple1():
     elem = html.HTML('<a></a>')
     assert elem.tag.name == 'a'
     assert len(elem) == 0
 
-def test_HTMLParser_simple2():
+def test_read_simple2():
     elem = html.HTML('<a><b /></a>')
     assert elem.tag.name == 'a'
     assert len(elem) == 1
     assert elem[0].tag.name == 'b'
     assert len(elem[0]) == 0
 
-def test_HTMLParser_text1():
+def test_read_text1():
     elem = html.HTML('<a>b</a>')
     assert elem.tag.name == 'a'
     assert isinstance(elem, tree.Element)
@@ -29,7 +28,7 @@
     assert elem[0] == 'b'
     assert isinstance(elem[0], unicode)
 
-def test_HTMLParser_text2():
+def test_read_text2():
     elem = html.HTML('<a>b<c>d</c>d</a>')
     assert elem.tag.name == 'a'
     assert len(elem) == 3
@@ -37,7 +36,7 @@
     assert elem[1].tag.name == 'c'
     assert elem[2] == 'd'
 
-def test_HTMLParser_ignoreend():
+def test_read_ignoreend():
     elem = html.HTML('<br>')
     assert elem.tag.name == 'br'
     assert len(elem) == 0
@@ -46,4 +45,6 @@
     assert elem.tag.name == 'br'
     assert len(elem) == 0
 
-
+def test_write():
+    elem = html.HTML(u'<br>')
+    assert serialize(elem) == u'<br>'