shared function to convert conditionally unicode strings to utf-8 strings, for use in tests

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32264 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 3810f5e4
......@@ -337,3 +337,13 @@ class LogInterceptor:
for handler in root_logger.handlers:
handler.removeFilter(self)
self.installed = tuple([s for s in self.installed if s != subsystem])
def to_utf8(text):
""" Converts string to utf-8 if string is unicode """
# BACK: The users of this function are probably reading the result of
# PageTemplate rendering, which is unicode in Zope 2.12, but string in Zope
# 2.8. When support for Zope 2.8 is dropped, rewrite the tests to assume
# the rendering is unicode and deal with it appropriately.
if isinstance(text, unicode):
text = text.encode('utf-8')
return text
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