############################################################################## # # Copyright (c) 2001, 2002 Zope Corporation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## """Basic Page Template tests $Id: test_basictemplate.py 72022 2007-01-14 13:45:26Z philikon $ """ import unittest from zope.pagetemplate.tests import util from zope.pagetemplate.pagetemplate import PageTemplate class BasicTemplateTests(unittest.TestCase): def setUp(self): self.t = PageTemplate() def test_if_in_var(self): # DTML test 1: if, in, and var: pass # for unittest """ %(comment)[ blah %(comment)]
%(if args)] %(else args)[ No arguments were given.
%(else args)] And thats da trooth. """ tal = util.read_input('dtml1.html') self.t.write(tal) aa = util.argv(('one', 'two', 'three', 'cha', 'cha', 'cha')) o = self.t(content=aa) expect = util.read_output('dtml1a.html') util.check_xml(expect, o) aa = util.argv(()) o = self.t(content=aa) expect = util.read_output('dtml1b.html') util.check_xml(expect, o) def test_template_usage(self): tal = util.read_input('template_usage.html') self.t.write(tal) o = self.t(template_usage=u"test") expect = util.read_output('template_usage1.html') util.check_xml(expect, o) o = self.t(template_usage=u"retest") expect = util.read_output('template_usage2.html') util.check_xml(expect, o) o = self.t(template_usage=u"other") expect = util.read_output('template_usage3.html') util.check_xml(expect, o) o = self.t(template_usage=u"") expect = util.read_output('template_usage4.html') util.check_xml(expect, o) def test_batches_and_formatting(self): # DTML test 3: batches and formatting: pass # for unittest """
And I\'m 100% sure! """ tal = util.read_input('dtml3.html') self.t.write(tal) aa = util.argv(('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty', )) from zope.pagetemplate.tests import batch o = self.t(content=aa, batch=batch.batch(aa.args, 5)) expect = util.read_output('dtml3.html') util.check_xml(expect, o) def test_on_error_in_slot_filler(self): # The `here` isn't defined, so the macro definition is # expected to catch the error that gets raised. text = '''\
\xe4\xf6\xfc\xdf
' # test with HTML parser self.t.pt_edit(text, 'text/html') self.assertEquals(self.t().strip(), text) # test with XML parser self.t.pt_edit(text, 'text/xml') self.assertEquals(self.t().strip(), text) def test_suite(): return unittest.makeSuite(BasicTemplateTests) if __name__ == '__main__': unittest.TextTestRunner().run(test_suite())