Commit 04a1efe8 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Use iHotfix.originalStringIO rather than re-importing StringIO to make sure...

Use iHotfix.originalStringIO rather than re-importing StringIO to make sure that unit tests use the same class.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@16839 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 73a2cc6e
......@@ -80,17 +80,17 @@ try:
# ZopeTestCase REQUESTs
ZopeTestCase.installProduct('iHotfix', quiet=install_product_quiet)
from Products import iHotfix
from StringIO import StringIO as OrigStringIO
from types import UnicodeType
# revert monkey patchs from iHotfix
iHotfix.get_request = get_request
class UnicodeSafeStringIO(OrigStringIO):
originalStringIO = iHotfix.originalStringIO
class UnicodeSafeStringIO(originalStringIO):
"""StringIO like class which never fails with unicode."""
def write(self, s):
if isinstance(s, UnicodeType):
s = s.encode('utf8', 'repr')
OrigStringIO.write(self, s)
originalStringIO.write(self, s)
# iHotFix will patch PageTemplate StringIO with
iHotfix.iHotfixStringIO = UnicodeSafeStringIO
except ImportError:
......
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