def test_end_with_args(self): tmpl = OldTextTemplate( """ #if foo bar #end 'if foo'""" ) self.assertEqual("\n", tmpl.generate(foo=False).render(encoding=None))
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())
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())
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))
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), )
def test_comment(self): tmpl = OldTextTemplate('## a comment') self.assertEqual('', str(tmpl.generate()))
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')))
def test_end_with_args(self): tmpl = OldTextTemplate(""" #if foo bar #end 'if foo'""") self.assertEqual('\n', str(tmpl.generate(foo=False)))
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')))
def test_comment_escaping(self): tmpl = OldTextTemplate('\\## escaped comment') self.assertEqual('## escaped comment', tmpl.generate().render(encoding=None))
def test_comment(self): tmpl = OldTextTemplate('## a comment') self.assertEqual('', tmpl.generate().render(encoding=None))
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))
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))
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))
def test_comment_escaping(self): tmpl = OldTextTemplate('\\## escaped comment') self.assertEqual('## escaped comment', str(tmpl.generate()))
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))
def test_escaping(self): tmpl = OldTextTemplate('\\#escaped') self.assertEqual('#escaped', str(tmpl.generate()))
def test_end_with_args(self): tmpl = OldTextTemplate(""" #if foo bar #end 'if foo'""") self.assertEqual('\n', tmpl.generate(foo=False).render(encoding=None))
def test_escaping(self): tmpl = OldTextTemplate("\\#escaped") self.assertEqual("#escaped", tmpl.generate().render(encoding=None))