Example #1
0
 def test_escaping(self):
     e = cubictemp._Expression(
         "foo", "@",
         0, "foo", {}
     )
     f = e.render(foo="<>")
     assert "&lt;" in f
     assert not "<" in f
     assert not ">" in f
Example #2
0
 def test_escaping(self):
     e = cubictemp._Expression(
         "foo", "@",
         0, "foo", {}
     )
     f = e.render(foo="<>")
     assert "&lt;" in f
     assert not "<" in f
     assert not ">" in f
Example #3
0
 def test_unescaped(self):
     class T:
         _cubictemp_unescaped = True
         def __str__(self):
             return "<>"
     t = T()
     e = cubictemp._Expression("foo", "@", 0, "foo", {})
     f = e.render(foo=t)
     assert "<" in f
     assert ">" in f
Example #4
0
 def test_unescaped(self):
     class T:
         _cubictemp_unescaped = True
         def __str__(self):
             return "<>"
     t = T()
     e = cubictemp._Expression("foo", "@", 0, "foo", {})
     f = e.render(foo=t)
     assert "<" in f
     assert ">" in f
Example #5
0
 def test_render(self):
     e = cubictemp._Expression("foo", "@", 0, self.s, {})
     assert e.render(foo="bar") == "bar"
     f = cubictemp._Expression("foo", "%", 0, self.s, {})
     assert f.render(foo="bar") == "bar"
Example #6
0
 def test_call(self):
     t = cubictemp._Iterable("foo", "bar", 0, "foo", {})
     t.append(cubictemp._Expression("bar", "@", 0, "foo", {}))
     assert t.render(foo=[1, 2, 3]) == "123"
Example #7
0
 def test_namerr(self):
     e = cubictemp._Expression("foo", "@", 0, self.s, {})
     libpry.raises(
         "NameError",
         e.render,
     )
Example #8
0
 def test_block(self):
     e = cubictemp._Expression("foo", "@", 0, self.s, {})
     t = cubictemp._Block(None, 0, self.s, {})
     t.append(cubictemp._Text("bar"))
     assert e.render(foo=t) == "bar"
Example #9
0
 def test_render(self):
     e = cubictemp._Expression("foo", "@", 0, self.s, {})
     assert e.render(foo="bar") == "bar"
Example #10
0
 def test_call(self):
     t = cubictemp._Iterable("foo", "bar", 0, "foo", {})
     t.append(cubictemp._Expression("bar", "@", 0, "foo", {}))
     assert t.render(foo=[1, 2, 3]) == "123"
Example #11
0
 def test_namerr(self):
     e = cubictemp._Expression("foo", "@", 0, self.s, {})
     libpry.raises(
         "NameError",
         e.render,
     )
Example #12
0
 def test_block(self):
     e = cubictemp._Expression("foo", "@", 0, self.s, {})
     t = cubictemp._Block(None, 0, self.s, {})
     t.append(cubictemp._Text("bar"))
     assert e.render(foo=t) == "bar"