diff options
| author | Jannis Leidel <jannis@leidel.info> | 2010-02-26 17:00:42 +0000 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2010-02-26 17:00:42 +0000 |
| commit | 7c23a5303cb5b5d01e6fb25d30676a5e95db2ecc (patch) | |
| tree | da58e606be3501138d6ffa0b57cebb2ec53e67bc /tests | |
| parent | 079d9f37383d3b44bbfffcee56925d82b3d838a9 (diff) | |
[1.1.X] Fixed #5971 - Fixed inconsistent behaviour of the TokenParser when parsing filters that follow constant strings or variables. Thanks Dmitri Fedortchenko, Adam Vandenberg and Ramiro Morales.
Backport of r12471.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@12610 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/templates/parser.py | 49 | ||||
| -rw-r--r-- | tests/regressiontests/templates/tests.py | 4 |
2 files changed, 52 insertions, 1 deletions
diff --git a/tests/regressiontests/templates/parser.py b/tests/regressiontests/templates/parser.py index 6b59896437..4db54556ed 100644 --- a/tests/regressiontests/templates/parser.py +++ b/tests/regressiontests/templates/parser.py @@ -2,6 +2,55 @@ Testing some internals of the template processing. These are *not* examples to be copied in user code. """ +token_parsing=r""" +Tests for TokenParser behavior in the face of quoted strings with spaces. + +>>> from django.template import TokenParser + + +Test case 1: {% tag thevar|filter sometag %} + +>>> p = TokenParser("tag thevar|filter sometag") +>>> p.tagname +'tag' +>>> p.value() +'thevar|filter' +>>> p.more() +True +>>> p.tag() +'sometag' +>>> p.more() +False + +Test case 2: {% tag "a value"|filter sometag %} + +>>> p = TokenParser('tag "a value"|filter sometag') +>>> p.tagname +'tag' +>>> p.value() +'"a value"|filter' +>>> p.more() +True +>>> p.tag() +'sometag' +>>> p.more() +False + +Test case 3: {% tag 'a value'|filter sometag %} + +>>> p = TokenParser("tag 'a value'|filter sometag") +>>> p.tagname +'tag' +>>> p.value() +"'a value'|filter" +>>> p.more() +True +>>> p.tag() +'sometag' +>>> p.more() +False +""" + filter_parsing = r""" >>> from django.template import FilterExpression, Parser diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py index 9c01b492e3..43a6c284ec 100644 --- a/tests/regressiontests/templates/tests.py +++ b/tests/regressiontests/templates/tests.py @@ -22,7 +22,7 @@ from django.utils.tzinfo import LocalTimezone from context import context_tests from custom import custom_filters -from parser import filter_parsing, variable_parsing +from parser import token_parsing, filter_parsing, variable_parsing from unicode import unicode_tests try: @@ -36,7 +36,9 @@ import filters __test__ = { 'unicode': unicode_tests, 'context': context_tests, + 'token_parsing': token_parsing, 'filter_parsing': filter_parsing, + 'variable_parsing': variable_parsing, 'custom_filters': custom_filters, } |
