def testSetMacro(self):
     self.assertEqual(moody.render("{% set 'foo' as test %}{{test}}"),
                      "foo")
     self.assertEqual(
         moody.render(
             "{% set 'foo', 'bar', as test1, test2 %}{{test1}}{{test2}}"),
         "foobar")
     self.assertEqual(moody.render("{% set 'foo', as test1, %}{{test1}}"),
                      "foo")
     self.assertRaises(TemplateRenderError,
                       lambda: moody.render("{% set 'foo', as foo, bar %}"))
     self.assertRaises(
         TemplateRenderError,
         lambda: moody.render("{% set 'foo', 'bar'  as bar, %}"))
 def testCommentTag(self):
     self.assertEqual(moody.render("{# A comment. #}"), "")
     self.assertEqual(moody.render("{# Multi\nLine\nComment #}"), "")
 def testImportMacro(self):
     self.assertEqual(
         moody.render("{% from operator import add %}{{add(1,1)}}"), "2")
     self.assertEqual(
         moody.render("{% import operator %}{{operator.add(1,1)}}"), "2")
 def testStringTag(self):
     self.assertEqual(moody.render("Hello world"), "Hello world")
 def testExpressionTag(self):
     self.assertEqual(moody.render("{{'Hello world'}}"), "Hello world")
     self.assertEqual(moody.render("{{('Hello '\n'world')}}"),
                      "Hello world")
Example #6
0
 def testCommentTag(self):
     self.assertEqual(moody.render("{# A comment. #}"), "")
     self.assertEqual(moody.render("{# Multi\nLine\nComment #}"), "")
Example #7
0
 def testImportMacro(self):
     self.assertEqual(moody.render("{% from operator import add %}{{add(1,1)}}"), "2")
     self.assertEqual(moody.render("{% import operator %}{{operator.add(1,1)}}"), "2")
Example #8
0
 def testSetMacro(self):
     self.assertEqual(moody.render("{% set 'foo' as test %}{{test}}"), "foo")
     self.assertEqual(moody.render("{% set 'foo', 'bar', as test1, test2 %}{{test1}}{{test2}}"), "foobar")
     self.assertEqual(moody.render("{% set 'foo', as test1, %}{{test1}}"), "foo")
     self.assertRaises(TemplateRenderError, lambda: moody.render("{% set 'foo', as foo, bar %}"))
     self.assertRaises(TemplateRenderError, lambda: moody.render("{% set 'foo', 'bar'  as bar, %}"))
Example #9
0
 def testExpressionTag(self):
     self.assertEqual(moody.render("{{'Hello world'}}"), "Hello world")
     self.assertEqual(moody.render("{{('Hello '\n'world')}}"), "Hello world")
Example #10
0
 def testStringTag(self):
     self.assertEqual(moody.render("Hello world"), "Hello world")