def test_escaping(self): e = cubictemp._Expression( "foo", "@", 0, "foo", {} ) f = e.render(foo="<>") assert "<" in f assert not "<" in f assert not ">" in f
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
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"
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"
def test_namerr(self): e = cubictemp._Expression("foo", "@", 0, self.s, {}) libpry.raises( "NameError", e.render, )
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"
def test_render(self): e = cubictemp._Expression("foo", "@", 0, self.s, {}) assert e.render(foo="bar") == "bar"