diff options
Diffstat (limited to 'src/Tests/Unicode.py')
-rw-r--r-- | src/Tests/Unicode.py | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/Tests/Unicode.py b/src/Tests/Unicode.py new file mode 100644 index 0000000..8b50980 --- /dev/null +++ b/src/Tests/Unicode.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python +# -*- encoding: utf8 -*- + +from Cheetah.Template import Template +import traceback +import unittest_local_copy as unittest # This is stupid + +class JPQ_UTF8_Test1(unittest.TestCase): + def runTest(self): + t = Template.compile(source="""Main file with |$v| + + $other""") + + otherT = Template.compile(source="Other template with |$v|") + other = otherT() + t.other = other + + t.v = u'Unicode String' + t.other.v = u'Unicode String' + + assert t() + +class JPQ_UTF8_Test2(unittest.TestCase): + def runTest(self): + t = Template.compile(source="""Main file with |$v| + + $other""") + + otherT = Template.compile(source="Other template with |$v|") + other = otherT() + t.other = other + + t.v = u'Unicode String with eacute é' + t.other.v = u'Unicode String' + + assert unicode(t()) + assert t().__str__() + + +class JPQ_UTF8_Test3(unittest.TestCase): + def runTest(self): + t = Template.compile(source="""Main file with |$v| + + $other""") + + otherT = Template.compile(source="Other template with |$v|") + other = otherT() + t.other = other + + t.v = u'Unicode String with eacute é' + t.other.v = u'Unicode String and an eacute é' + + assert unicode(t()) + +class JPQ_UTF8_Test4(unittest.TestCase): + def runTest(self): + t = Template.compile(source="""Main file with |$v| and eacute in the template é""") + + t.v = 'Unicode String' + + assert t() + +class JPQ_UTF8_Test5(unittest.TestCase): + def runTest(self): + t = Template.compile(source="""#encoding utf-8 + Main file with |$v| and eacute in the template é""") + + t.v = u'Unicode String' + rc = t().__str__() + assert rc + +if __name__ == '__main__': + unittest.main() |