New submission from STINNER Victor <victor.stin...@haypocalc.com>: On a failure, unittest does its best to display values. But sometimes, the output doesn't help me. Example:
FAIL: test_listdir (test.test_pep277.UnicodeFileTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/db3l/buildarea/3.x.bolen-tiger/build/Lib/test/test_pep277.py", line 157, in test_listdir self.assertEqual(sf0, sf2) AssertionError: Items in the first set but not the second: '@test_18608_tmp/ ̈ÌÎ¥ÌΫ' '@test_18608_tmp/ẛ῁῍᾿Ì῏῝῾Ì῟῭' Items in the second set but not the first: '@test_18608_tmp/ ̈ÌΥΥÌ̈' '@test_18608_tmp/ẛ῁῍᾿Ì᾿῾῾῾῁̀Ì͂̀' '@test_18608_tmp/¨ÌÏ’Ï’Ì̈' This is a test on unicode filenames. I would prefer to see non-ASCII characters as \xHH or \uXXXX than strange characters or boxes. Do you think that it is a good idea to replace calls to repr() by ascii() in the unittest library? In Python2, repr(unicode) escapes all non-ASCII characters. But in Python3, only control characters and surrogates are escaped. So the output depends on the terminal encoding. Write non-ASCII characters in a backtrace may also raise a new error if the terminal is unable to a character. Raise an error while printing an error is just horrible :-) -- Attached patch is a try to replace repr() by ascii() in the unittest module. But I don't know this library, so don't trust the patch :-) ---------- components: Library (Lib), Unicode files: unittest_ascii.patch keywords: patch messages: 119248 nosy: haypo priority: normal severity: normal status: open title: unittest: use ascii() instead of repr() to display values on error versions: Python 3.2 Added file: http://bugs.python.org/file19311/unittest_ascii.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue10161> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com