# @@: Note, this is an experimental (TDD) test from sqlobject import * from formencode.formgen import makeform from formencode.fields import Context from formencode.doctest_xml_compare import xml_compare, make_xml from formencode import sqlformgen sqlhub.processConnection = connectionForURI('sqlite:/:memory:') CONTEXT = Context() CONTEXT.secret = 'foo' def printer(s): print s def xcmp(a, b): try: a = '%s' % a xml_a = make_xml(a) except: print prxml(a) raise try: b = '%s' % b xml_b = make_xml(b) except: print prxml(b) raise prxml(a) prxml(b) assert xml_compare(xml_a, xml_b, reporter=printer) def prxml(xml): for lineno, line in enumerate(xml.splitlines()): print '%2i %s' % (lineno+1, line) class SimpleForm(SQLObject): name = StringCol() address = StringCol() city = StringCol() SimpleForm.createTable() def test_simple(): f, v = makeform(SimpleForm, CONTEXT) yield (xcmp, f(requires_label=True).render(CONTEXT), """ name:
address:
city:
""") f.name = 'simp' yield (xcmp, f(requires_label=True).render(CONTEXT), """ name:
address:
city:
""") # This test isn't really ready, so we'll skip return s = SimpleForm(name='Tom', address='123', city='Chicago') f, v = makeform(s, CONTEXT) yield (xcmp, f(requires_label=True).render(CONTEXT), """ name:
address:
city:
""")