[issue8313] <unprintable AssertionError object> message in unittest tracebacks

Michael Foord report at bugs.python.org
Mon Apr 5 12:56:29 CEST 2010


New submission from Michael Foord <michael at voidspace.org.uk>:

>>> import unittest
>>> class Foo(unittest.TestCase):
...   def test_fffd(self): self.assertEqual(u'\ufffd', u'\ufffd\ufffd')
...
>>> unittest.main(exit=False)
F
======================================================================
FAIL: test_fffd (__main__.Foo)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "<stdin>", line 2, in test_fffd
AssertionError: <unprintable AssertionError object>

----------------------------------------------------------------------
Ran 1 test in 0.001s


The problem with creating unicode tracebacks is that they could fail when being output on terminals not capable of showing the full range of unicode characters (the default terminal on Windows is CP1252).

This can already happen with Unicode messages that aren't part of the traceback.

Detecting the 'unprintable' message before calling into traceback and replacing it with the repr of the unicode is one possibility.

----------
assignee: michael.foord
components: Library (Lib)
messages: 102368
nosy: ezio.melotti, michael.foord
severity: normal
status: open
title: <unprintable AssertionError object> message in unittest tracebacks
type: behavior
versions: Python 2.7, Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8313>
_______________________________________


More information about the Python-bugs-list mailing list