Django

Code

Changeset 5198

Show
Ignore:
Timestamp:
05/12/07 01:32:23 (2 years ago)
Author:
mtredinnick
Message:

unicode: Removed some duplicated code that had crept in. Some kind of tragic
"falling asleep on keyboard" accident whilst vim was open, I assume.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/unicode/tests/regressiontests/templates/unicode.py

    r4971 r5198  
    66>>> t1 = Template(u'ŠĐĆŽćžšđ {{ var }}') 
    77 
    8 Templates can also be created from bytestrings. These are assumed by encoded using UTF-8. 
     8Templates can also be created from bytestrings. These are assumed by encoded 
     9using UTF-8. 
     10 
    911>>> s = '\xc5\xa0\xc4\x90\xc4\x86\xc5\xbd\xc4\x87\xc5\xbe\xc5\xa1\xc4\x91 {{ var }}' 
    1012>>> t2 = Template(s) 
     
    1618 
    1719Contexts can be constructed from unicode or UTF-8 bytestrings. 
     20 
    1821>>> c1 = Context({'var': 'foo'}) 
    1922>>> c2 = Context({u'var': 'foo'}) 
     
    2326Since both templates and all four contexts represent the same thing, they all 
    2427render the same (and are returned as bytestrings). 
     28 
    2529>>> t1.render(c3) == t2.render(c3) 
    2630True 
     
    2832<type 'str'> 
    2933""" 
    30 # -*- coding: utf-8 -*- 
    31  
    32 unicode_tests = ur""" 
    33 Templates can be created from unicode strings. 
    34 >>> from django.template import * 
    35 >>> t1 = Template(u'ŠĐĆŽćžšđ {{ var }}') 
    36  
    37 Templates can also be created from bytestrings. These are assumed by encoded using UTF-8. 
    38 >>> s = '\xc5\xa0\xc4\x90\xc4\x86\xc5\xbd\xc4\x87\xc5\xbe\xc5\xa1\xc4\x91 {{ var }}' 
    39 >>> t2 = Template(s) 
    40 >>> s = '\x80\xc5\xc0' 
    41 >>> Template(s) 
    42 Traceback (most recent call last): 
    43     ... 
    44 TemplateEncodingError: Templates can only be constructed from unicode or UTF-8 strings. 
    45  
    46 Contexts can be constructed from unicode or UTF-8 bytestrings. 
    47 >>> c1 = Context({'var': 'foo'}) 
    48 >>> c2 = Context({u'var': 'foo'}) 
    49 >>> c3 = Context({'var': u'Đđ'}) 
    50 >>> c4 = Context({u'var': '\xc4\x90\xc4\x91'}) 
    51  
    52 Since both templates and all four contexts represent the same thing, they all 
    53 render the same (and are returned as bytestrings). 
    54 >>> t1.render(c3) == t2.render(c3) 
    55 True 
    56 >>> type(t1.render(c3)) 
    57 <type 'str'> 
    58 """