summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>2009-01-20 13:35:37 +0100
committerAdrien Di Mascio <Adrien.DiMascio@logilab.fr>2009-01-20 13:35:37 +0100
commitdda3f359d9cd34a08293026f7401893011111138 (patch)
tree2f72e080467c208c6c6b512f841ffa4b955e0c09
parentd432b81bdc55e78bd7c681b365af9fcb37610d4b (diff)
downloadlogilab-common-dda3f359d9cd34a08293026f7401893011111138.tar.gz
use traceback.formation_exception_only to be more error-resistant when displaying fancy tracebacks with unicode strings
-rw-r--r--test/unittest_testlib.py10
-rw-r--r--testlib.py2
2 files changed, 10 insertions, 2 deletions
diff --git a/test/unittest_testlib.py b/test/unittest_testlib.py
index f7034ed..25462cd 100644
--- a/test/unittest_testlib.py
+++ b/test/unittest_testlib.py
@@ -608,12 +608,20 @@ class OutErrCaptureTC(TestCase):
bootstrap_print("hello")
self.assertEquals(output.restore(), "hello")
- def test_exotic_unicode_string(self):
+ def test_unicode_non_ascii_messages(self):
class FooTC(TestCase):
def test_xxx(self):
raise Exception(u'\xe9')
test = FooTC('test_xxx')
result = self.runner.run(test)
+
+ def test_encoded_non_ascii_messages(self):
+ class FooTC(TestCase):
+ def test_xxx(self):
+ raise Exception('\xe9')
+ test = FooTC('test_xxx')
+ result = self.runner.run(test)
+
class DecoratorTC(TestCase):
diff --git a/testlib.py b/testlib.py
index 6090b22..15d2df3 100644
--- a/testlib.py
+++ b/testlib.py
@@ -409,7 +409,7 @@ class SkipAwareTestResult(unittest._TextTestResult):
output.append(' self.%s: %r' % (varname, value))
output.append(' ' + '-' * 66)
output.append('')
- output.append('%s: %s' % (exctype.__name__, exc))
+ output.append(''.join(traceback.format_exception_only(exctype, exc)))
return '\n'.join(output)
def addError(self, test, err):