Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merged toby-stiff-cache-branch and toby-unicode-branch
- Loading branch information
Toby Dickenson
committed
Mar 27, 2002
1 parent
bd615c1
commit a236b48
Showing
8 changed files
with
337 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
# split off into its own module for aliasing without circrefs | ||
|
||
from cgi import escape | ||
from ustr import ustr | ||
|
||
def html_quote(v, name='(Unknown name)', md={}): | ||
return escape(str(v), 1) | ||
return escape(ustr(v), 1) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
############################################################################## | ||
# | ||
# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved. | ||
# | ||
# This software is subject to the provisions of the Zope Public License, | ||
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. | ||
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED | ||
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS | ||
# FOR A PARTICULAR PURPOSE | ||
# | ||
############################################################################## | ||
"""Document Template Tests | ||
""" | ||
|
||
__rcs_id__='$Id: testDTMLUnicode.py,v 1.2 2002/03/27 10:14:02 htrd Exp $' | ||
__version__='$Revision: 1.2 $'[11:-2] | ||
|
||
import sys, os | ||
import unittest | ||
|
||
from DocumentTemplate.DT_HTML import HTML, String | ||
from ExtensionClass import Base | ||
|
||
class force_str: | ||
# A class whose string representation is not always a plain string: | ||
def __init__(self,s): | ||
self.s = s | ||
def __str__(self): | ||
return self.s | ||
|
||
class DTMLUnicodeTests (unittest.TestCase): | ||
|
||
doc_class = HTML | ||
|
||
def testAA(self): | ||
html=self.doc_class('<dtml-var a><dtml-var b>') | ||
expected = 'helloworld' | ||
res = html(a='hello',b='world') | ||
assert res == expected, `res` | ||
|
||
def testUU(self): | ||
html=self.doc_class('<dtml-var a><dtml-var b>') | ||
expected = u'helloworld' | ||
res = html(a=u'hello',b=u'world') | ||
assert res == expected, `res` | ||
|
||
def testAU(self): | ||
html=self.doc_class('<dtml-var a><dtml-var b>') | ||
expected = u'helloworld' | ||
res = html(a='hello',b=u'world') | ||
assert res == expected, `res` | ||
|
||
def testAB(self): | ||
html=self.doc_class('<dtml-var a><dtml-var b>') | ||
expected = 'hello\xc8' | ||
res = html(a='hello',b=chr(200)) | ||
assert res == expected, `res` | ||
|
||
def testUB(self): | ||
html=self.doc_class('<dtml-var a><dtml-var b>') | ||
expected = u'hello\xc8' | ||
res = html(a=u'hello',b=chr(200)) | ||
assert res == expected, `res` | ||
|
||
def testUB2(self): | ||
html=self.doc_class('<dtml-var a><dtml-var b>') | ||
expected = u'\u07d0\xc8' | ||
res = html(a=unichr(2000),b=chr(200)) | ||
assert res == expected, `res` | ||
|
||
def testUnicodeStr(self): | ||
html=self.doc_class('<dtml-var a><dtml-var b>') | ||
expected = u'\u07d0\xc8' | ||
res = html(a=force_str(unichr(2000)),b=chr(200)) | ||
assert res == expected, `res` | ||
|
||
def testUqB(self): | ||
html=self.doc_class('<dtml-var a html_quote><dtml-var b>') | ||
expected = u'he>llo\xc8' | ||
res = html(a=u'he>llo',b=chr(200)) | ||
assert res == expected, `res` | ||
|
||
def test_suite(): | ||
suite = unittest.TestSuite() | ||
suite.addTest( unittest.makeSuite( DTMLUnicodeTests ) ) | ||
return suite | ||
|
||
def main(): | ||
unittest.TextTestRunner().run(test_suite()) | ||
|
||
if __name__ == '__main__': | ||
main() |
Oops, something went wrong.