Revision: 17943e7cbd6c
Branch: default
Author: Pekka Klärck
Date: Wed Sep 12 03:58:41 2012
Log: utils.safe_repr: Add u prefix to repr of Unicode strings also
with IronPython. Ought to make some IPY test pass on CI.
http://code.google.com/p/robotframework/source/detail?r=17943e7cbd6c
Modified:
/src/robot/utils/unic.py
/utest/utils/test_unic.py
=======================================
--- /src/robot/utils/unic.py Tue Mar 6 00:46:30 2012
+++ /src/robot/utils/unic.py Wed Sep 12 03:58:41 2012
@@ -66,6 +66,15 @@
except:
return _unrepresentable_object(item)
+if sys.platform == 'cli':
+ _safe_repr = safe_repr
+ def safe_repr(item):
+ ret = _safe_repr(item)
+ # IronPython omits u prefix but we want to be consistent.
+ if isinstance(item, unicode) and not ret.startswith('u'):
+ ret = 'u' + ret
+ return ret
+
_unrepresentable_msg = u"<Unrepresentable object '%s'. Error: %s>"
=======================================
--- /utest/utils/test_unic.py Fri Oct 7 02:03:51 2011
+++ /utest/utils/test_unic.py Wed Sep 12 03:58:41 2012
@@ -80,6 +80,10 @@
assert_equals(safe_repr(ReprFails()),
_unrepresentable_msg % ('ReprFails', 'Failure in
__repr__'))
+ def test_repr_of_unicode_has_u_prefix(self):
+ assert_equals(safe_repr(u'foo'), "u'foo'")
+ assert_equals(safe_repr(u"f'o'o"), "u\"f'o'o\"")
+
class UnicodeRepr: