[Erp5-report] r32264 leonardo - /erp5/trunk/products/ERP5Type/tests/utils.py

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Feb 4 15:25:04 CET 2010


Author: leonardo
Date: Thu Feb  4 15:25:03 2010
New Revision: 32264

URL: http://svn.erp5.org?rev=32264&view=rev
Log:
shared function to convert conditionally unicode strings to utf-8 strings, for use in tests

Modified:
    erp5/trunk/products/ERP5Type/tests/utils.py

Modified: erp5/trunk/products/ERP5Type/tests/utils.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/utils.py?rev=32264&r1=32263&r2=32264&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/utils.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/utils.py [utf8] Thu Feb  4 15:25:03 2010
@@ -337,3 +337,13 @@
         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




More information about the Erp5-report mailing list