summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2010-02-22 23:34:33 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2010-02-22 23:34:33 +0000
commit49d6a82261feda6ee1bf23bb17184e932e232172 (patch)
treedbdf8122115f57461ed8e306f68160b48fa46479 /tests
parenteb0751a4c0b2d5e248ff3babc37a4764b102e25a (diff)
Fixed #11687: the `add` filter is now less failsome when faced with things that can't be coerced to integers.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12497 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/templates/filters.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/regressiontests/templates/filters.py b/tests/regressiontests/templates/filters.py
index d2e8e7473b..c39e34b999 100644
--- a/tests/regressiontests/templates/filters.py
+++ b/tests/regressiontests/templates/filters.py
@@ -333,4 +333,15 @@ def get_filter_tests():
'date02': (r'{{ d|date }}', {'d': datetime(2008, 1, 1)}, 'Jan. 1, 2008'),
#Ticket 9520: Make sure |date doesn't blow up on non-dates
'date03': (r'{{ d|date:"m" }}', {'d': 'fail_string'}, ''),
+
+ # base tests for add that assert, that old behaviour, which means
+ # trying to add two values as ints, is kept
+ 'add01': (r'{{ i|add:"5" }}', {'i': 2000}, '2005'),
+ 'add02': (r'{{ i|add:"napis" }}', {'i': 2000}, '2000'),
+ 'add03': (r'{{ i|add:16 }}', {'i': 'not_an_int'}, 'not_an_int'),
+ 'add04': (r'{{ i|add:"16" }}', {'i': 'not_an_int'}, 'not_an_int16'),
+ # further additions using dynamic typing
+ 'add05': (r'{{ l1|add:l2 }}', {'l1': [1, 2], 'l2': [3, 4]}, '[1, 2, 3, 4]'),
+ 'add06': (r'{{ t1|add:t2 }}', {'t1': (3, 4), 't2': (1, 2)}, '(3, 4, 1, 2)'),
+ 'add07': (r'{{ d|add:t }}', {'d': date(2000, 1, 1), 't': timedelta(10)}, '2000-01-11'),
}