From a5c075c4e2ebeb31263938c3b0d382fc81008f3f Mon Sep 17 00:00:00 2001 From: Floris Bruynooghe Date: Sun, 24 Nov 2013 17:45:48 +0000 Subject: [PATCH] Respect unicode in AssertionError argument This is related to issue319 --- _pytest/assertion/reinterpret.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/_pytest/assertion/reinterpret.py b/_pytest/assertion/reinterpret.py index f7a0b2d56..c598ec882 100644 --- a/_pytest/assertion/reinterpret.py +++ b/_pytest/assertion/reinterpret.py @@ -2,17 +2,17 @@ import sys import py from _pytest.assertion.util import BuiltinAssertionError + class AssertionError(BuiltinAssertionError): def __init__(self, *args): BuiltinAssertionError.__init__(self, *args) if args: try: - self.msg = str(args[0]) - except py.builtin._sysex: - raise - except: - self.msg = "<[broken __repr__] %s at %0xd>" %( - args[0].__class__, id(args[0])) + self.msg = py.builtin._totext(args[0]) + except Exception: + self.msg = py.builtin._totext( + "<[broken __repr__] %s at %0xd> %s" + % (args[0].__class__, id(args[0]))) else: f = py.code.Frame(sys._getframe(1)) try: