コード例 #1
0
 def testNone(self):
     """Test that a dict with None as a value resolves correctly."""
     self.assertEqual(
         render_targs({"a": None}),
         {"a": None}
     )
コード例 #2
0
 def testList(self):
     """Verify that lists can be used as values and manipulated by the template."""
     self.assertEqual(
         render_targs({"a": "{{b|join(' ')}}", "b": ["foo", "bar"]}),
         {"a": "foo bar", "b": ["foo", "bar"]}
     )
コード例 #3
0
 def testResolves(self):
     """Verify that a dict with legal values resolves correctly."""
     self.assertEqual(
         render_targs({"a": "{{ b }}", "b": "{{c}}", "c": "d"}),
         {"a": "d", "b": "d", "c": "d"}
     )
コード例 #4
0
 def testSelfReference(self):
     """Test for failure when a targ refers to itself."""
     with self.assertRaises(UnresolvableTemplate) as r:
         render_targs({"a": "{{a}}"})
     self.assertIn("a={{a}}", str(r.exception))
コード例 #5
0
 def testMissingValue(self):
     """Test for failure when a template value is not provided."""
     with self.assertRaises(UnresolvableTemplate) as r:
         render_targs({"a": "{{b}}"})
     self.assertIn("Missing template value:", str(r.exception))
コード例 #6
0
 def testCirularReference_twoVarsWithText(self):
     with self.assertRaises(UnresolvableTemplate) as r:
         render_targs({"a": "the {{b}}", "b": "only {{a}}"})
     self.assertIn("a=the {{b}}, b=only {{a}}", str(r.exception))
コード例 #7
0
 def testCircularReference_varWithText(self):
     """Test for failure when there is a circular reference in targs."""
     with self.assertRaises(UnresolvableTemplate) as r:
         render_targs({"a": "{{b}}", "b": "foo {{c}}", "c": "{{a}}"})
     self.assertIn("a={{b}}, b=foo {{c}}, c={{a}}", str(r.exception))
コード例 #8
0
 def testMutualReference(self):
     """Test for failure when targs refer directly to each other."""
     with self.assertRaises(UnresolvableTemplate) as r:
         render_targs({"a": "{{b}}", "b": "{{a}}"})
     self.assertIn("a={{b}}, b={{a}}", str(r.exception))
コード例 #9
0
    def testVarWithSpace(self):
        """Verify spaces are not allowed inside of jinja template variables.

        (and we don't expect it)."""
        with self.assertRaises(jinja2.exceptions.TemplateSyntaxError):
            render_targs({"abc def": "foo", "ghi jkl": "{{abc def}}"})
コード例 #10
0
 def testBool(self):
     """Test that a dict with a bool as a value resolves correctly."""
     self.assertEqual(
         render_targs({"a": True}),
         {"a": True}
     )