mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #26479 -- Added 'is not' operator to the if tag.
This commit is contained in:
parent
c10db4bd1b
commit
c16b9dd8e0
4 changed files with 33 additions and 4 deletions
|
@ -537,3 +537,15 @@ class IfTagTests(SimpleTestCase):
|
|||
def test_if_is_no_match(self):
|
||||
output = self.engine.render_to_string('template', {'foo': 1})
|
||||
self.assertEqual(output, 'no')
|
||||
|
||||
@setup({'template': '{% if foo is not None %}yes{% else %}no{% endif %}'})
|
||||
def test_if_is_not_match(self):
|
||||
# For this to act as a regression test, it's important not to use
|
||||
# foo=True because True is (not None)
|
||||
output = self.engine.render_to_string('template', {'foo': False})
|
||||
self.assertEqual(output, 'yes')
|
||||
|
||||
@setup({'template': '{% if foo is not None %}yes{% else %}no{% endif %}'})
|
||||
def test_if_is_not_no_match(self):
|
||||
output = self.engine.render_to_string('template', {'foo': None})
|
||||
self.assertEqual(output, 'no')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue