def test_3(self):
        self.folder.laf.write(util.read_input('teeshoplaf.html'))

        t = self.folder.t
        t.write(util.read_input('teeshop1.html'))
        expect = util.read_output('teeshop1.html')
        out = t(laf = self.folder.laf, getProducts = self.getProducts)
        util.check_html(expect, out)
    def test_if_in_var(self):
        # DTML test 1: if, in, and var:
        pass # for unittest
        """
        %(comment)[ blah %(comment)]
        <html><head><title>Test of documentation templates</title></head>
        <body>
        %(if args)[
        <dl><dt>The arguments to this test program were:<p>
        <dd>
        <ul>
        %(in args)[
          <li>Argument number %(num)d was %(arg)s
        %(in args)]
        </ul></dl><p>
        %(if args)]
        %(else args)[
        No arguments were given.<p>
        %(else args)]
        And thats da trooth.
        </body></html>
        """
        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)
Example #3
0
    def test_translation(self):
        from zope.i18nmessageid import MessageFactory
        _ = MessageFactory('pttest')
        msg = _("Translate this!")

        t = self.folder.t
        t.write(util.read_input('translation.html'))
        expect = util.read_output('translation.html')
        out = t(msg=msg)
        util.check_html(expect, out)
    def test_translation(self):
        from zope.i18nmessageid import MessageFactory
        _ = MessageFactory('pttest')
        msg = _("Translate this!")

        t = self.folder.t
        t.write(util.read_input('translation.html'))
        expect = util.read_output('translation.html')
        out = t(msg=msg)
        util.check_html(expect, out)
Example #5
0
 def test_recursion(self):
     t = self.folder.t
     t.write(util.read_input('recursive.html'))
     expect = util.read_output('recursive.html')
     context = dict(name='root',
                    children=[dict(name='first', children=[]),
                              dict(name='second', children=[])])
     namespace = dict(template=t, options={}, args=(),
                      nothing=None, context=context)
     out = t.pt_render(namespace)
     # crude way of normalizing whitespace
     expect = expect.replace(' ', '').replace('\n\n', '\n')
     out = out.replace(' ', '').replace('\n\n', '\n')
     util.check_html(expect, out)
     # https://bugs.launchpad.net/zope.pagetemplate/+bug/732972
     errors = t.pt_errors(namespace, check_macro_expansion=False)
     self.assertFalse(errors)
    def test_batches_and_formatting(self):
        # DTML test 3: batches and formatting:
        pass # for unittest
        """
          <html><head><title>Test of documentation templates</title></head>
          <body>
          <!--#if args-->
            The arguments were:
            <!--#in args size=size end=end-->
                <!--#if previous-sequence-->
                   (<!--#var previous-sequence-start-arg-->-
                    <!--#var previous-sequence-end-arg-->)
                <!--#/if previous-sequence-->
                <!--#if sequence-start-->
                   <dl>
                <!--#/if sequence-start-->
                <dt><!--#var sequence-arg-->.</dt>
                <dd>Argument <!--#var num fmt=d--> was <!--#var arg--></dd>
                <!--#if next-sequence-->
                   (<!--#var next-sequence-start-arg-->-
                    <!--#var next-sequence-end-arg-->)
                <!--#/if next-sequence-->
            <!--#/in args-->
            </dl>
          <!--#else args-->
            No arguments were given.<p>
          <!--#/if args-->
          And I\'m 100% sure!
          </body></html>
        """
        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)
Example #7
0
    def test_batches_and_formatting(self):
        # DTML test 3: batches and formatting:
        pass # for unittest
        """
          <html><head><title>Test of documentation templates</title></head>
          <body>
          <!--#if args-->
            The arguments were:
            <!--#in args size=size end=end-->
                <!--#if previous-sequence-->
                   (<!--#var previous-sequence-start-arg-->-
                    <!--#var previous-sequence-end-arg-->)
                <!--#/if previous-sequence-->
                <!--#if sequence-start-->
                   <dl>
                <!--#/if sequence-start-->
                <dt><!--#var sequence-arg-->.</dt>
                <dd>Argument <!--#var num fmt=d--> was <!--#var arg--></dd>
                <!--#if next-sequence-->
                   (<!--#var next-sequence-start-arg-->-
                    <!--#var next-sequence-end-arg-->)
                <!--#/if next-sequence-->
            <!--#/in args-->
            </dl>
          <!--#else args-->
            No arguments were given.<p>
          <!--#/if args-->
          And I\'m 100% sure!
          </body></html>
        """
        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)
Example #8
0
    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_recursion(self):
     t = self.folder.t
     t.write(util.read_input('recursive.html'))
     expect = util.read_output('recursive.html')
     context = dict(name='root',
                    children=[
                        dict(name='first', children=[]),
                        dict(name='second', children=[])
                    ])
     namespace = dict(template=t,
                      options={},
                      args=(),
                      nothing=None,
                      context=context)
     out = t.pt_render(namespace)
     # crude way of normalizing whitespace
     expect = expect.replace(' ', '').replace('\n\n', '\n')
     out = out.replace(' ', '').replace('\n\n', '\n')
     util.check_html(expect, out)
     # https://bugs.launchpad.net/zope.pagetemplate/+bug/732972
     errors = t.pt_errors(namespace, check_macro_expansion=False)
     self.assertFalse(errors)
 def test_1(self):
     laf = self.folder.laf
     laf.write(util.read_input('teeshoplaf.html'))
     expect = util.read_output('teeshoplaf.html')
     util.check_html(expect, laf())
 def test_NotExpression(self):
     t = self.folder.t
     t.write(util.read_input('checknotexpression.html'))
     expect = util.read_output('checknotexpression.html')
     out = t()
     util.check_html(expect, out)
 def test_PathAlt(self):
     t = self.folder.t
     t.write(util.read_input('checkpathalt.html'))
     expect = util.read_output('checkpathalt.html')
     out = t()
     util.check_html(expect, out)
 def test_WithXMLHeader(self):
     t = self.folder.t
     t.write(util.read_input('checkwithxmlheader.html'))
     expect = util.read_output('checkwithxmlheader.html')
     out = t()
     util.check_html(expect, out)
 def test_WithXMLHeader(self):
     t = self.folder.t
     t.write(util.read_input('checkwithxmlheader.html'))
     expect = util.read_output('checkwithxmlheader.html')
     out = t()
     util.check_html(expect, out)
 def test_StringExpressions(self):
     t = self.folder.t
     t.write(util.read_input('stringexpression.html'))
     expect = util.read_output('stringexpression.html')
     out = t()
     util.check_html(expect, out)
 def test_ReplaceWithNothing(self):
     t = self.folder.t
     t.write(util.read_input('checknothing.html'))
     expect = util.read_output('checknothing.html')
     out = t()
     util.check_html(expect, out)
 def test_NotExpression(self):
     t = self.folder.t
     t.write(util.read_input('checknotexpression.html'))
     expect = util.read_output('checknotexpression.html')
     out = t()
     util.check_html(expect, out)
 def test_StringExpressions(self):
     t = self.folder.t
     t.write(util.read_input('stringexpression.html'))
     expect = util.read_output('stringexpression.html')
     out = t()
     util.check_html(expect, out)
 def test_SimpleLoop(self):
     t = self.folder.t
     t.write(util.read_input('loop1.html'))
     expect = util.read_output('loop1.html')
     out = t()
     util.check_html(expect, out)
 def test_1(self):
     laf = self.folder.laf
     laf.write(util.read_input('teeshoplaf.html'))
     expect = util.read_output('teeshoplaf.html')
     util.check_html(expect, laf())
 def test_PathAlt(self):
     t = self.folder.t
     t.write(util.read_input('checkpathalt.html'))
     expect = util.read_output('checkpathalt.html')
     out = t()
     util.check_html(expect, out)
 def test_GlobalsShadowLocals(self):
     t = self.folder.t
     t.write(util.read_input('globalsshadowlocals.html'))
     expect = util.read_output('globalsshadowlocals.html')
     out = t()
     util.check_html(expect, out)
 def test_SimpleLoop(self):
     t = self.folder.t
     t.write(util.read_input('loop1.html'))
     expect = util.read_output('loop1.html')
     out = t()
     util.check_html(expect, out)
 def test_ReplaceWithNothing(self):
     t = self.folder.t
     t.write(util.read_input('checknothing.html'))
     expect = util.read_output('checknothing.html')
     out = t()
     util.check_html(expect, out)
 def test_GlobalsShadowLocals(self):
     t = self.folder.t
     t.write(util.read_input('globalsshadowlocals.html'))
     expect = util.read_output('globalsshadowlocals.html')
     out = t()
     util.check_html(expect, out)