On Fri, Jan 17, 2014 at 10:16 PM, Robin Becker <ro...@reportlab.com> wrote: > Aside from changing the tests so they look like > """ > >>> func(u'aaa')==u'aaa' > True > """
Do your test strings contain any non-ASCII characters? If not, you might be able to do this: def func(a): """ >>> str(func(u'aaa')) 'aaa' """ return a which should work in both. In Py3, the str() call will do nothing, and it'll compare correctly; in Py2, it'll convert it into a byte string, which will repr() without the 'u'. I don't think it's possible to monkey-patch unicode.__repr__ to not put the u'' prefix on, but if there is a way, that'd possibly be more convenient. ChrisA -- https://mail.python.org/mailman/listinfo/python-list