[Checkins] SVN: zope.tales/trunk/src/zope/tales/tests/test_expressions.py document behaviour and failure modes reported in https://bugs.launchpad.net/zope2/+bug/246983
Leonardo Rochael Almeida
leorochael at gmail.com
Thu Dec 31 17:15:06 EST 2009
Log message for revision 107480:
document behaviour and failure modes reported in https://bugs.launchpad.net/zope2/+bug/246983
Changed:
U zope.tales/trunk/src/zope/tales/tests/test_expressions.py
-=-
Modified: zope.tales/trunk/src/zope/tales/tests/test_expressions.py
===================================================================
--- zope.tales/trunk/src/zope/tales/tests/test_expressions.py 2009-12-31 21:41:57 UTC (rev 107479)
+++ zope.tales/trunk/src/zope/tales/tests/test_expressions.py 2009-12-31 22:15:05 UTC (rev 107480)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
@@ -66,6 +67,7 @@
B = 2,
adapterTest = at,
dynamic = 'z',
+ eightBits = 'déjà vu',
ErrorGenerator = ErrorGenerator(),
)
)
@@ -125,7 +127,9 @@
def testString(self):
expr = self.engine.compile('string:Fred')
context=self.context
- self.assertEqual(expr(context), 'Fred')
+ result = expr(context)
+ self.assertEqual(result, 'Fred')
+ self.failUnless(isinstance(result, str))
def testStringSub(self):
expr = self.engine.compile('string:A$B')
@@ -136,7 +140,27 @@
expr = self.engine.compile('string:a ${x/y} b ${y/z} c')
context=self.context
self.assertEqual(expr(context), 'a yikes b 3 c')
+
+ def testString8Bits(self):
+ # Simple eight bit string interpolation should just work.
+ expr = self.engine.compile('string:a ${eightBits}')
+ context=self.context
+ self.assertEqual(expr(context), 'a déjà vu')
+ def testStringUnicode(self):
+ # Unicode string expressions should return unicode strings
+ expr = self.engine.compile(u'string:Fred')
+ context=self.context
+ result = expr(context)
+ self.assertEqual(result, u'Fred')
+ self.failUnless(isinstance(result, unicode))
+
+ def testStringFailureWhenMixed(self):
+ # Mixed Unicode and 8bit string interpolation fails with a
+ # UnicodeDecodeError, assuming there is no default encoding
+ expr = self.engine.compile(u'string:a ${eightBits}')
+ self.assertRaises(UnicodeDecodeError, expr, self.context)
+
def testPython(self):
expr = self.engine.compile('python: 2 + 2')
context=self.context
More information about the checkins
mailing list