Skip to content

Commit 2e3fdc6

Browse files
committed
Fixed #11288: added some tests for the handling of number-like variables in templates.
Thanks, Stephen Kelly. git-svn-id: http://code.djangoproject.com/svn/django/trunk@13460 bcc190cf-cafb-0310-a4f2-bffc1f526a37
1 parent 88f2f0b commit 2e3fdc6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/regressiontests/templates/tests.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,17 @@ def get_template_tests(self):
506506
'basic-syntax28': ("{{ a.b }}", {'a': SilentGetItemClass()}, ('', 'INVALID')),
507507
'basic-syntax29': ("{{ a.b }}", {'a': SilentAttrClass()}, ('', 'INVALID')),
508508

509+
# Something that starts like a number but has an extra lookup works as a lookup.
510+
'basic-syntax30': ("{{ 1.2.3 }}", {"1": {"2": {"3": "d"}}}, "d"),
511+
'basic-syntax31': ("{{ 1.2.3 }}", {"1": {"2": ("a", "b", "c", "d")}}, "d"),
512+
'basic-syntax32': ("{{ 1.2.3 }}", {"1": (("x", "x", "x", "x"), ("y", "y", "y", "y"), ("a", "b", "c", "d"))}, "d"),
513+
'basic-syntax33': ("{{ 1.2.3 }}", {"1": ("xxxx", "yyyy", "abcd")}, "d"),
514+
'basic-syntax34': ("{{ 1.2.3 }}", {"1": ({"x": "x"}, {"y": "y"}, {"z": "z", "3": "d"})}, "d"),
515+
516+
# Numbers are numbers even if their digits are in the context.
517+
'basic-syntax35': ("{{ 1 }}", {"1": "abc"}, "1"),
518+
'basic-syntax36': ("{{ 1.2 }}", {"1": "abc"}, "1.2"),
519+
509520
# List-index syntax allows a template to access a certain item of a subscriptable object.
510521
'list-index01': ("{{ var.1 }}", {"var": ["first item", "second item"]}, "second item"),
511522

0 commit comments

Comments
 (0)