1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #26118 -- Added 'is' operator to if template tag.

This commit is contained in:
Preston Timmons
2016-01-21 21:50:06 -06:00
committed by Tim Graham
parent a08d2463d2
commit c00ae7f58c
4 changed files with 25 additions and 1 deletions

View File

@@ -527,3 +527,13 @@ class IfTagTests(SimpleTestCase):
# A single equals sign is a syntax error.
with self.assertRaises(TemplateSyntaxError):
self.engine.render_to_string('if-tag-single-eq', {'foo': 1})
@setup({'template': '{% if foo is True %}yes{% else %}no{% endif %}'})
def test_if_is_match(self):
output = self.engine.render_to_string('template', {'foo': True})
self.assertEqual(output, 'yes')
@setup({'template': '{% if foo is True %}yes{% else %}no{% endif %}'})
def test_if_is_no_match(self):
output = self.engine.render_to_string('template', {'foo': 1})
self.assertEqual(output, 'no')