"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "Cheetah/Tests/Unicode.py" between
cheetah3-3.1.0.tar.gz and cheetah3-3.2.0.tar.gz

About: Cheetah3 is a template engine and code generation tool for e.g. for Web development or Java, SQL, LaTeX, form email ... (written in Python).

Unicode.py  (cheetah3-3.1.0):Unicode.py  (cheetah3-3.2.0)
#!/usr/bin/env python #!/usr/bin/env python
# -*- encoding: utf8 -*- # -*- encoding: utf8 -*-
from glob import glob from glob import glob
import imp import imp
import os import os
import sys import sys
from shutil import rmtree from shutil import rmtree
import tempfile import tempfile
import unittest import unittest
from Cheetah.Compiler import Compiler
from Cheetah.Template import Template from Cheetah.Template import Template
from Cheetah import CheetahWrapper from Cheetah import CheetahWrapper
from Cheetah.compat import PY2, unicode from Cheetah.compat import PY2, unicode
class CommandLineTest(unittest.TestCase): class CommandLineTest(unittest.TestCase):
def createAndCompile(self, source): def createAndCompile(self, source):
sourcefile = '-' sourcefile = '-'
while sourcefile.find('-') != -1: while sourcefile.find('-') != -1:
sourcefile = tempfile.mktemp() sourcefile = tempfile.mktemp()
skipping to change at line 206 skipping to change at line 207
# The string is something in Thai # The string is something in Thai
source = '''This is $foo $adjective''' source = '''This is $foo $adjective'''
template = self.createAndCompile(source) template = self.createAndCompile(source)
assert template and issubclass(template, Template) assert template and issubclass(template, Template)
template = template( template = template(
searchList=[{ searchList=[{
'foo': 'bar', 'foo': 'bar',
'adjective': 'adjective':
u'\u0e22\u0e34\u0e19\u0e14\u0e35\u0e15' u'\u0e22\u0e34\u0e19\u0e14\u0e35\u0e15'
u'\u0e49\u0e2d\u0e19\u0e23\u0e31\u0e1a' u'\u0e49\u0e2d\u0e19\u0e23\u0e31\u0e1a'
}]) }])
assert template.respond() assert template.respond()
def test_Thai_utf8(self): def test_Thai_utf8(self):
utf8 = '\xe0\xb8\xa2\xe0\xb8\xb4\xe0\xb8\x99\xe0' \ utf8 = '\xe0\xb8\xa2\xe0\xb8\xb4\xe0\xb8\x99\xe0' \
'\xb8\x94\xe0\xb8\xb5\xe0\xb8\x95\xe0\xb9\x89\xe0' \ '\xb8\x94\xe0\xb8\xb5\xe0\xb8\x95\xe0\xb9\x89\xe0' \
'\xb8\xad\xe0\xb8\x99\xe0\xb8\xa3\xe0\xb8\xb1\xe0\xb8\x9a' '\xb8\xad\xe0\xb8\x99\xe0\xb8\xa3\xe0\xb8\xb1\xe0\xb8\x9a'
source = '''This is $adjective''' source = '''This is $adjective'''
template = self.createAndCompile(source) template = self.createAndCompile(source)
assert template and issubclass(template, Template) assert template and issubclass(template, Template)
skipping to change at line 261 skipping to change at line 262
def test_success(self): def test_success(self):
""" Test a template with a proper #encoding tag """ """ Test a template with a proper #encoding tag """
template = '#encoding utf-8\n%s' % self.template template = '#encoding utf-8\n%s' % self.template
template = Template(template, searchList=[{'header': '', template = Template(template, searchList=[{'header': '',
'nombre': '', 'nombre': '',
'numpedidos_bodega': '', 'numpedidos_bodega': '',
'numpedidos_noconf': ''}]) 'numpedidos_noconf': ''}])
self.assertTrue(unicode(template)) self.assertTrue(unicode(template))
class CompilerTest(unittest.TestCase):
def test_compiler_str(self):
""" Test Compiler.__str__ """
source = """#encoding utf-8
#set $someUnicodeString = u"Bébé"
$someUnicodeString"""
compiler = Compiler(source)
self.assertIsInstance(str(compiler), str)
self.assertEqual(compiler.getModuleEncoding(), 'utf-8')
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
 End of changes. 3 change blocks. 
1 lines changed or deleted 12 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)