[Zope-Checkins] SVN: Zope/trunk/lib/python/Products/PageTemplates/
added tests for edgecase where the resolver has no REQUEST object
Andreas Jung
andreas at andreas-jung.com
Sat Aug 2 08:36:56 EDT 2008
Log message for revision 89211:
added tests for edgecase where the resolver has no REQUEST object
Changed:
U Zope/trunk/lib/python/Products/PageTemplates/tests/testZopePageTemplate.py
U Zope/trunk/lib/python/Products/PageTemplates/unicodeconflictresolver.py
-=-
Modified: Zope/trunk/lib/python/Products/PageTemplates/tests/testZopePageTemplate.py
===================================================================
--- Zope/trunk/lib/python/Products/PageTemplates/tests/testZopePageTemplate.py 2008-08-02 12:25:15 UTC (rev 89210)
+++ Zope/trunk/lib/python/Products/PageTemplates/tests/testZopePageTemplate.py 2008-08-02 12:36:55 UTC (rev 89211)
@@ -339,7 +339,24 @@
result = zpt.pt_render()
self.assertEqual('ATTR' in result, False)
+class PreferredEncodingUnicodeResolverTests(unittest.TestCase):
+ def testPreferredCharsetResolverWithoutRequestAndWithoutEncoding(self):
+ # This test checks the edgecase where the unicode conflict resolver
+ # is called with a context object having no REQUEST
+ context = object()
+ result = PreferredCharsetResolver.resolve(context, 'üöä', None)
+ self.assertEqual(result, 'üöä')
+
+ def testPreferredCharsetResolverWithoutRequestAndWithEncoding(self):
+ # This test checks the edgecase where the unicode conflict resolver
+ # is called with a context object having no REQUEST
+ class ContextMock:
+ management_page_charset = 'iso-8859-15'
+ result = PreferredCharsetResolver.resolve(ContextMock(), 'üöä', None)
+ self.assertEqual(result, u'üöä')
+
+
class ZPTRegressions(unittest.TestCase):
def setUp(self):
@@ -463,6 +480,7 @@
suite.addTests(unittest.makeSuite(ZPTMacros))
suite.addTests(unittest.makeSuite(ZopePageTemplateFileTests))
suite.addTests(unittest.makeSuite(ZPTUnicodeEncodingConflictResolution))
+ suite.addTests(unittest.makeSuite(PreferredEncodingUnicodeResolverTests))
return suite
if __name__ == '__main__':
Modified: Zope/trunk/lib/python/Products/PageTemplates/unicodeconflictresolver.py
===================================================================
--- Zope/trunk/lib/python/Products/PageTemplates/unicodeconflictresolver.py 2008-08-02 12:25:15 UTC (rev 89210)
+++ Zope/trunk/lib/python/Products/PageTemplates/unicodeconflictresolver.py 2008-08-02 12:36:55 UTC (rev 89211)
@@ -67,6 +67,7 @@
# Deal with the fact that a REQUEST is not always available.
# In this case fall back to the encoding of the ZMI and the
# Python default encoding.
+
if request is None:
charsets = [default_encoding]
management_charset = getattr(context, 'management_page_charset', None)
More information about the Zope-Checkins
mailing list