Commit 2e3fdc63 authored by Jacob Kaplan-Moss's avatar Jacob Kaplan-Moss
Browse files

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
parent 88f2f0b3
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -506,6 +506,17 @@ class Templates(unittest.TestCase):
            'basic-syntax28': ("{{ a.b }}", {'a': SilentGetItemClass()}, ('', 'INVALID')),
            'basic-syntax29': ("{{ a.b }}", {'a': SilentAttrClass()}, ('', 'INVALID')),

            # Something that starts like a number but has an extra lookup works as a lookup. 
            'basic-syntax30': ("{{ 1.2.3 }}", {"1": {"2": {"3": "d"}}}, "d"), 
            'basic-syntax31': ("{{ 1.2.3 }}", {"1": {"2": ("a", "b", "c", "d")}}, "d"), 
            'basic-syntax32': ("{{ 1.2.3 }}", {"1": (("x", "x", "x", "x"), ("y", "y", "y", "y"), ("a", "b", "c", "d"))}, "d"), 
            'basic-syntax33': ("{{ 1.2.3 }}", {"1": ("xxxx", "yyyy", "abcd")}, "d"), 
            'basic-syntax34': ("{{ 1.2.3 }}", {"1": ({"x": "x"}, {"y": "y"}, {"z": "z", "3": "d"})}, "d"), 
            
            # Numbers are numbers even if their digits are in the context. 
            'basic-syntax35': ("{{ 1 }}", {"1": "abc"}, "1"), 
            'basic-syntax36': ("{{ 1.2 }}", {"1": "abc"}, "1.2"), 

            # List-index syntax allows a template to access a certain item of a subscriptable object.
            'list-index01': ("{{ var.1 }}", {"var": ["first item", "second item"]}, "second item"),