예제 #1
0
 def test_doctype(self):
     page = TempyPage()
     page.set_doctype('html_strict')
     charset_string = 'HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"'
     self.assertTrue(charset_string in page.render())
예제 #2
0
파일: bench.py 프로젝트: wwintermute/TemPy
    for x in range(100)
]

page = TempyPage()
pr = cProfile.Profile()
pr.enable()
for _ in range(100):
    page.body(Div()(table=Table()(Tr(id='%s' % i)(
        Td(klass='CIAO', id='%s-%s' % (i, td))(cont=td) for td in tr.values())
                                  for i, tr in enumerate(TABLE_DATA))))
pr.disable()
s = StringIO()
sortby = 'tottime'
ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
print('*' * 200)
print('CREATION')
ps.print_stats()
print(s.getvalue())

pr = cProfile.Profile()
pr.enable()
_ = page.render()
pr.disable()
s = StringIO()
sortby = 'tottime'
ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
print('*' * 200)
print('RENDERING')
ps.print_stats()
print(s.getvalue())