[Zope-Checkins]
SVN: Zope/branches/2.10/lib/python/Products/PageTemplates/tests/testExpressions.py
merge from HEAD
Andreas Jung
andreas at andreas-jung.com
Mon Jan 8 08:57:35 EST 2007
Log message for revision 71807:
merge from HEAD
Changed:
U Zope/branches/2.10/lib/python/Products/PageTemplates/tests/testExpressions.py
-=-
Modified: Zope/branches/2.10/lib/python/Products/PageTemplates/tests/testExpressions.py
===================================================================
--- Zope/branches/2.10/lib/python/Products/PageTemplates/tests/testExpressions.py 2007-01-08 13:56:43 UTC (rev 71806)
+++ Zope/branches/2.10/lib/python/Products/PageTemplates/tests/testExpressions.py 2007-01-08 13:57:34 UTC (rev 71807)
@@ -1,12 +1,20 @@
import unittest
+import zope.component
import zope.component.testing
from zope.traversing.adapters import DefaultTraversable
from Products.PageTemplates import Expressions
from Products.PageTemplates.DeferExpr import LazyWrapper
from Products.PageTemplates.DeferExpr import DeferWrapper
+from Products.PageTemplates.unicodeconflictresolver import \
+ DefaultUnicodeEncodingConflictResolver, \
+ StrictUnicodeEncodingConflictResolver, \
+ ReplacingUnicodeEncodingConflictResolver, \
+ IgnoringUnicodeEncodingConflictResolver
+from Products.PageTemplates.interfaces import IUnicodeEncodingConflictResolver
+
class Dummy:
__allow_access_to_unprotected_subobjects__ = 1
def __call__(self):
@@ -107,8 +115,38 @@
self.assertEquals(ec.evaluate(''), None)
self.assertEquals(ec.evaluate(' \n'), None)
+
+class UnicodeEncodingConflictResolverTests(zope.component.testing.PlacelessSetup, unittest.TestCase):
+
+ def testDefaultResolver(self):
+ zope.component.provideUtility(DefaultUnicodeEncodingConflictResolver,
+ IUnicodeEncodingConflictResolver)
+ resolver = zope.component.getUtility(IUnicodeEncodingConflictResolver)
+ self.assertRaises(UnicodeDecodeError, resolver.resolve, None, 'äüö', None)
+
+ def testStrictResolver(self):
+ zope.component.provideUtility(StrictUnicodeEncodingConflictResolver,
+ IUnicodeEncodingConflictResolver)
+ resolver = zope.component.getUtility(IUnicodeEncodingConflictResolver)
+ self.assertRaises(UnicodeDecodeError, resolver.resolve, None, 'äüö', None)
+
+ def testIgnoringResolver(self):
+ zope.component.provideUtility(IgnoringUnicodeEncodingConflictResolver,
+ IUnicodeEncodingConflictResolver)
+ resolver = zope.component.getUtility(IUnicodeEncodingConflictResolver)
+ self.assertEqual(resolver.resolve(None, 'äüö', None), '')
+
+ def testReplacingResolver(self):
+ zope.component.provideUtility(ReplacingUnicodeEncodingConflictResolver,
+ IUnicodeEncodingConflictResolver)
+ resolver = zope.component.getUtility(IUnicodeEncodingConflictResolver)
+ self.assertEqual(resolver.resolve(None, 'äüö', None), u'\ufffd\ufffd\ufffd')
+
def test_suite():
- return unittest.makeSuite(ExpressionTests)
+ return unittest.TestSuite((
+ unittest.makeSuite(ExpressionTests),
+ unittest.makeSuite(UnicodeEncodingConflictResolverTests)
+ ))
if __name__=='__main__':
main()
More information about the Zope-Checkins
mailing list