diff options
| author | Luke Plant <L.Plant.98@cantab.net> | 2010-03-08 23:25:37 +0000 |
|---|---|---|
| committer | Luke Plant <L.Plant.98@cantab.net> | 2010-03-08 23:25:37 +0000 |
| commit | 960af90279081e7a4121736f3f2bc67077f11b31 (patch) | |
| tree | b886c53a203dacdd717a30da98e2ca2dc5f04ef4 /tests | |
| parent | 021ba30ad1d4fffada4f2d43d47a4704bcfca45e (diff) | |
Fixed #13058 - "smart if" template tag doesn't support "if not in ..." condition
Thanks to ramusus for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12732 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/templates/smartif.py | 7 | ||||
| -rw-r--r-- | tests/regressiontests/templates/tests.py | 6 |
2 files changed, 13 insertions, 0 deletions
diff --git a/tests/regressiontests/templates/smartif.py b/tests/regressiontests/templates/smartif.py index 0114753830..5e5d7704e7 100644 --- a/tests/regressiontests/templates/smartif.py +++ b/tests/regressiontests/templates/smartif.py @@ -27,6 +27,13 @@ class SmartIfTests(unittest.TestCase): self.assertCalcEqual(False, [1, 'in', None]) self.assertCalcEqual(False, [None, 'in', list_]) + def test_not_in(self): + list_ = [1,2,3] + self.assertCalcEqual(False, [1, 'not', 'in', list_]) + self.assertCalcEqual(True, [4, 'not', 'in', list_]) + self.assertCalcEqual(False, [1, 'not', 'in', None]) + self.assertCalcEqual(True, [None, 'not', 'in', list_]) + def test_precedence(self): # (False and False) or True == True <- we want this one, like Python # False and (False or True) == False diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py index 1af3637158..e603ec33c2 100644 --- a/tests/regressiontests/templates/tests.py +++ b/tests/regressiontests/templates/tests.py @@ -611,6 +611,12 @@ class Templates(unittest.TestCase): 'if-tag-lte-01': ("{% if 1 <= 1 %}yes{% else %}no{% endif %}", {}, "yes"), 'if-tag-lte-02': ("{% if 2 <= 1 %}yes{% else %}no{% endif %}", {}, "no"), + # Contains + 'if-tag-in-01': ("{% if 1 in x %}yes{% else %}no{% endif %}", {'x':[1]}, "yes"), + 'if-tag-in-02': ("{% if 2 in x %}yes{% else %}no{% endif %}", {'x':[1]}, "no"), + 'if-tag-not-in-01': ("{% if 1 not in x %}yes{% else %}no{% endif %}", {'x':[1]}, "no"), + 'if-tag-not-in-02': ("{% if 2 not in x %}yes{% else %}no{% endif %}", {'x':[1]}, "yes"), + # AND 'if-tag-and01': ("{% if foo and bar %}yes{% else %}no{% endif %}", {'foo': True, 'bar': True}, 'yes'), 'if-tag-and02': ("{% if foo and bar %}yes{% else %}no{% endif %}", {'foo': True, 'bar': False}, 'no'), |
