import py from py.__.rest.rst import * from py.__.rest.transform import * def convert_to_html(tree): handler = HTMLHandler() t = RestTransformer(tree) t.parse(handler) return handler.html class HTMLHandler(py.__.rest.transform.HTMLHandler): def startDocument(self): pass endDocument = startDocument def test_transform_basic_html(): for rest, expected in ((Rest(Title('foo')), '
foo
'), (Rest(SubParagraph('foo')), 'foo
'), (Rest(LiteralBlock('foo\tbar')), 'foo\tbar'), (Rest(Paragraph(Link('foo', 'http://www.foo.com/'))), ('
\n foo' '
'))): html = convert_to_html(rest) assert html == expected def test_transform_list_simple(): rest = Rest(ListItem('foo'), ListItem('bar')) html = convert_to_html(rest) assert html == '