def test_truthy_thingy(self): templ = Tortoise('{% if items %}we have items{% end %}') self.assertEquals(templ.render({'items': []}), '') rv = Tortoise('{% if items %}we have items{% end %}').render({ 'items': None}) self.assertEquals(rv, '') rv = Tortoise('{% if items %}we have items{% end %}').render({ 'items': ''}) self.assertEquals(rv, '') rv = Tortoise('{% if items %}we have items{% end %}').render({ 'items': [1]}) self.assertEquals(rv, 'we have items')
def test_reusability(self): # A single template can be used more than once with different data template = Tortoise("This is {{ name }}") self.assertEqual(template.render({'name': 'Foo'}), 'This is Foo') self.assertEqual(template.render({'name': 'Bar'}), 'This is Bar')