Beispiel #1
0
    def test_1(self):
        """DTML test 1: if, in, and var:

        %(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.__of__(aa)()
        expect = util.read_output('DTML1a.html')

        util.check_xml(expect, o)

        aa = util.argv(())
        o = self.t.__of__(aa)()
        expect = util.read_output('DTML1b.html')
        util.check_xml(expect, o)
Beispiel #2
0
    def test_1(self):
        """DTML test 1: if, in, and var:

        %(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.__of__(aa)()
        expect = util.read_output('DTML1a.html')

        util.check_xml(expect, o)

        aa = util.argv(())
        o = self.t.__of__(aa)()
        expect = util.read_output('DTML1b.html')
        util.check_xml(expect, o)
 def assert_expected_unicode(self, t, fname, *args, **kwargs):
     t.write(util.read_input(fname))
     assert not t._v_errors, 'Template errors: %s' % t._v_errors
     expect = util.read_output(fname)
     expect = unicode(expect, 'utf8')
     out = apply(t, args, kwargs)
     util.check_html(expect, out)
Beispiel #4
0
 def assert_expected_unicode(self, t, fname, *args, **kwargs):
     t.write(util.read_input(fname))
     assert not t._v_errors, 'Template errors: %s' % t._v_errors
     expect = util.read_output(fname)
     expect = unicode(expect, 'utf8')
     out = t(*args, **kwargs)
     util.check_html(expect, out)
Beispiel #5
0
    def test_3(self):
        """DTML test 3: batches and formatting:

          <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 Products.PageTemplates.tests import batch
        o = self.t.__of__(aa)(batch=batch.batch(aa.args, 5))

        expect = util.read_output('DTML3.html')
        util.check_xml(expect, o)
Beispiel #6
0
 def assert_expected_unicode(self, t, fname, *args, **kwargs):
     t.write(util.read_input(fname))
     assert not t._v_errors, 'Template errors: %s' % t._v_errors
     expect = util.read_output(fname)
     if not isinstance(expect, text_type):
         expect = text_type(expect, 'utf-8')
     out = t(*args, **kwargs)
     util.check_html(expect, out)
Beispiel #7
0
 def assert_expected(self, t, fname, *args, **kwargs):
     t.write(util.read_input(fname))
     assert not t._v_errors, 'Template errors: %s' % t._v_errors
     if self.PREFIX is not None \
             and util.exists_output(self.PREFIX + fname):
         fname = self.PREFIX + fname
     expect = util.read_output(fname)
     out = t(*args, **kwargs)
     util.check_html(expect, out)
Beispiel #8
0
    def test_3(self):
        """DTML test 3: batches and formatting:

          <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 Products.PageTemplates.tests import batch
        o = self.t.__of__(aa)(batch=batch.batch(aa.args, 5))

        expect = util.read_output('DTML3.html')
        util.check_xml(expect, o)
Beispiel #9
0
 def assert_expected(self, t, fname, *args, **kwargs):
     t.write(util.read_input(fname))
     assert not t._v_errors, 'Template errors: %s' % t._v_errors
     expect = util.read_output(fname)
     out = t(*args, **kwargs)
     util.check_html(expect, out)