diff options
| author | Alasdair Nicol <alasdair@thenicols.net> | 2016-04-28 22:51:40 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-04-29 12:38:46 -0400 |
| commit | dac075e9103ba961af4f70b4011616daa72985d4 (patch) | |
| tree | 7b1e5d4328c8d652e4a16a5798059fdc505a63b4 /tests/template_tests/syntax_tests/test_if.py | |
| parent | 246020efc59de1a64b52fdda6a460904151dae36 (diff) | |
Refs #26479 -- Documented is/is not if tag operator behavior for nonexistent variables.
Diffstat (limited to 'tests/template_tests/syntax_tests/test_if.py')
| -rw-r--r-- | tests/template_tests/syntax_tests/test_if.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/template_tests/syntax_tests/test_if.py b/tests/template_tests/syntax_tests/test_if.py index 861a9818d2..703f3d352c 100644 --- a/tests/template_tests/syntax_tests/test_if.py +++ b/tests/template_tests/syntax_tests/test_if.py @@ -564,6 +564,16 @@ class IfTagTests(SimpleTestCase): output = self.engine.render_to_string('template', {'foo': 1}) self.assertEqual(output, 'no') + @setup({'template': '{% if foo is bar %}yes{% else %}no{% endif %}'}) + def test_if_is_variable_missing(self): + output = self.engine.render_to_string('template', {'foo': 1}) + self.assertEqual(output, 'no') + + @setup({'template': '{% if foo is bar %}yes{% else %}no{% endif %}'}) + def test_if_is_both_variables_missing(self): + output = self.engine.render_to_string('template', {}) + self.assertEqual(output, 'yes') + @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 @@ -575,3 +585,13 @@ class IfTagTests(SimpleTestCase): def test_if_is_not_no_match(self): output = self.engine.render_to_string('template', {'foo': None}) self.assertEqual(output, 'no') + + @setup({'template': '{% if foo is not bar %}yes{% else %}no{% endif %}'}) + def test_if_is_not_variable_missing(self): + output = self.engine.render_to_string('template', {'foo': False}) + self.assertEqual(output, 'yes') + + @setup({'template': '{% if foo is not bar %}yes{% else %}no{% endif %}'}) + def test_if_is_not_both_variables_missing(self): + output = self.engine.render_to_string('template', {}) + self.assertEqual(output, 'no') |
