Commit 168d3c2e authored by Andreas Jung's avatar Andreas Jung

merge from HEAD

parent 6118ff0d
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
......@@ -107,8 +115,38 @@ class ExpressionTests(zope.component.testing.PlacelessSetup, unittest.TestCase):
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()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment