diff options
author | Alasdair Nicol <alasdair@thenicols.net> | 2016-04-28 23:01:44 +0100 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2016-04-29 12:31:12 -0400 |
commit | cd2ac512e6f4bd0bb848d9cb65b1831b63116531 (patch) | |
tree | f1dbd7c41ff538c41cf8b9ea8f9d6ed57eea9e0a | |
parent | 999e0231257e451c6432838d251039c708148686 (diff) | |
download | django-cd2ac512e6f4bd0bb848d9cb65b1831b63116531.tar.gz |
[1.9.x] Added tests for if tag's != operator.
Backport of 246020efc59de1a64b52fdda6a460904151dae36 from master
-rw-r--r-- | tests/template_tests/syntax_tests/test_if.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/template_tests/syntax_tests/test_if.py b/tests/template_tests/syntax_tests/test_if.py index 6bbf2598a1..d529cb60e5 100644 --- a/tests/template_tests/syntax_tests/test_if.py +++ b/tests/template_tests/syntax_tests/test_if.py @@ -112,6 +112,32 @@ class IfTagTests(SimpleTestCase): output = self.engine.render_to_string('if-tag-eq05') self.assertEqual(output, 'no') + # Inequality + @setup({'if-tag-noteq01': '{% if foo != bar %}yes{% else %}no{% endif %}'}) + def test_if_tag_noteq01(self): + output = self.engine.render_to_string('if-tag-noteq01') + self.assertEqual(output, 'no') + + @setup({'if-tag-noteq02': '{% if foo != bar %}yes{% else %}no{% endif %}'}) + def test_if_tag_noteq02(self): + output = self.engine.render_to_string('if-tag-noteq02', {'foo': 1}) + self.assertEqual(output, 'yes') + + @setup({'if-tag-noteq03': '{% if foo != bar %}yes{% else %}no{% endif %}'}) + def test_if_tag_noteq03(self): + output = self.engine.render_to_string('if-tag-noteq03', {'foo': 1, 'bar': 1}) + self.assertEqual(output, 'no') + + @setup({'if-tag-noteq04': '{% if foo != bar %}yes{% else %}no{% endif %}'}) + def test_if_tag_noteq04(self): + output = self.engine.render_to_string('if-tag-noteq04', {'foo': 1, 'bar': 2}) + self.assertEqual(output, 'yes') + + @setup({'if-tag-noteq05': '{% if foo != "" %}yes{% else %}no{% endif %}'}) + def test_if_tag_noteq05(self): + output = self.engine.render_to_string('if-tag-noteq05') + self.assertEqual(output, 'yes') + # Comparison @setup({'if-tag-gt-01': '{% if 2 > 1 %}yes{% else %}no{% endif %}'}) def test_if_tag_gt_01(self): |