1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

[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
This commit is contained in:
Jannis Leidel
2010-02-26 17:00:42 +00:00
parent 079d9f3738
commit 7c23a5303c
4 changed files with 72 additions and 10 deletions

View File

@@ -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