Exemple #1
0
 def test_end_with_args(self):
     tmpl = OldTextTemplate(
         """
     #if foo
       bar
     #end 'if foo'"""
     )
     self.assertEqual("\n", tmpl.generate(foo=False).render(encoding=None))
Exemple #2
0
    def test_empty_lines1(self):
        tmpl = OldTextTemplate("""Your items:

        #for item in items
          * ${item}
        #end""")
        self.assertEqual("""Your items:

          * 0
          * 1
          * 2
""", tmpl.generate(items=range(3)).render())
Exemple #3
0
    def test_empty_lines1(self):
        tmpl = OldTextTemplate("""Your items:

        #for item in items
          * ${item}
        #end""")
        self.assertEqual(
            """Your items:

          * 0
          * 1
          * 2
""",
            tmpl.generate(items=range(3)).render())
Exemple #4
0
    def test_empty_lines2(self):
        tmpl = OldTextTemplate("""Your items:

        #for item in items
          * ${item}

        #end""")
        self.assertEqual(
            """Your items:

          * 0

          * 1

          * 2

""",
            tmpl.generate(items=list(range(3))).render(encoding=None))
Exemple #5
0
    def test_empty_lines2(self):
        tmpl = OldTextTemplate(
            """Your items:

        #for item in items
          * ${item}

        #end"""
        )
        self.assertEqual(
            """Your items:

          * 0

          * 1

          * 2

""",
            tmpl.generate(items=list(range(3))).render(encoding=None),
        )
Exemple #6
0
 def test_comment(self):
     tmpl = OldTextTemplate('## a comment')
     self.assertEqual('', str(tmpl.generate()))
Exemple #7
0
 def test_unicode_input(self):
     text = u'$foo\xf6$bar'
     tmpl = OldTextTemplate(text)
     self.assertEqual(u'x\xf6y', unicode(tmpl.generate(foo='x', bar='y')))
Exemple #8
0
 def test_end_with_args(self):
     tmpl = OldTextTemplate("""
     #if foo
       bar
     #end 'if foo'""")
     self.assertEqual('\n', str(tmpl.generate(foo=False)))
Exemple #9
0
 def test_comment(self):
     tmpl = OldTextTemplate('## a comment')
     self.assertEqual('', str(tmpl.generate()))
Exemple #10
0
 def test_latin1_encoded(self):
     text = u'$foo\xf6$bar'.encode('iso-8859-1')
     tmpl = OldTextTemplate(text, encoding='iso-8859-1')
     self.assertEqual(u'x\xf6y', unicode(tmpl.generate(foo='x', bar='y')))
Exemple #11
0
 def test_comment_escaping(self):
     tmpl = OldTextTemplate('\\## escaped comment')
     self.assertEqual('## escaped comment',
                      tmpl.generate().render(encoding=None))
Exemple #12
0
 def test_comment(self):
     tmpl = OldTextTemplate('## a comment')
     self.assertEqual('', tmpl.generate().render(encoding=None))
Exemple #13
0
 def test_latin1_encoded(self):
     text = '$foo\xf6$bar'.encode('iso-8859-1')
     tmpl = OldTextTemplate(text, encoding='iso-8859-1')
     self.assertEqual('x\xf6y',
                      tmpl.generate(foo='x', bar='y').render(encoding=None))
Exemple #14
0
 def test_unicode_input(self):
     text = "$foo\xf6$bar"
     tmpl = OldTextTemplate(text)
     self.assertEqual("x\xf6y", tmpl.generate(foo="x", bar="y").render(encoding=None))
Exemple #15
0
 def test_latin1_encoded(self):
     text = "$foo\xf6$bar".encode("iso-8859-1")
     tmpl = OldTextTemplate(text, encoding="iso-8859-1")
     self.assertEqual("x\xf6y", tmpl.generate(foo="x", bar="y").render(encoding=None))
Exemple #16
0
 def test_comment_escaping(self):
     tmpl = OldTextTemplate('\\## escaped comment')
     self.assertEqual('## escaped comment', str(tmpl.generate()))
Exemple #17
0
 def test_end_with_args(self):
     tmpl = OldTextTemplate("""
     #if foo
       bar
     #end 'if foo'""")
     self.assertEqual('\n', str(tmpl.generate(foo=False)))
Exemple #18
0
 def test_unicode_input(self):
     text = u'$foo\xf6$bar'
     tmpl = OldTextTemplate(text)
     self.assertEqual(u'x\xf6y',
                      tmpl.generate(foo='x', bar='y').render(encoding=None))
Exemple #19
0
 def test_unicode_input(self):
     text = u'$foo\xf6$bar'
     tmpl = OldTextTemplate(text)
     self.assertEqual(u'x\xf6y', unicode(tmpl.generate(foo='x', bar='y')))
Exemple #20
0
 def test_comment(self):
     tmpl = OldTextTemplate('## a comment')
     self.assertEqual('', tmpl.generate().render(encoding=None))
Exemple #21
0
 def test_escaping(self):
     tmpl = OldTextTemplate('\\#escaped')
     self.assertEqual('#escaped', str(tmpl.generate()))
Exemple #22
0
 def test_comment_escaping(self):
     tmpl = OldTextTemplate('\\## escaped comment')
     self.assertEqual('## escaped comment',
                      tmpl.generate().render(encoding=None))
Exemple #23
0
 def test_comment_escaping(self):
     tmpl = OldTextTemplate('\\## escaped comment')
     self.assertEqual('## escaped comment', str(tmpl.generate()))
Exemple #24
0
 def test_end_with_args(self):
     tmpl = OldTextTemplate("""
     #if foo
       bar
     #end 'if foo'""")
     self.assertEqual('\n', tmpl.generate(foo=False).render(encoding=None))
Exemple #25
0
 def test_latin1_encoded(self):
     text = u'$foo\xf6$bar'.encode('iso-8859-1')
     tmpl = OldTextTemplate(text, encoding='iso-8859-1')
     self.assertEqual(u'x\xf6y', unicode(tmpl.generate(foo='x', bar='y')))
Exemple #26
0
 def test_unicode_input(self):
     text = u'$foo\xf6$bar'
     tmpl = OldTextTemplate(text)
     self.assertEqual(u'x\xf6y',
                      tmpl.generate(foo='x', bar='y').render(encoding=None))
Exemple #27
0
 def test_escaping(self):
     tmpl = OldTextTemplate('\\#escaped')
     self.assertEqual('#escaped', str(tmpl.generate()))
Exemple #28
0
 def test_escaping(self):
     tmpl = OldTextTemplate("\\#escaped")
     self.assertEqual("#escaped", tmpl.generate().render(encoding=None))