Merge another unicode fix.

This commit is contained in:
Jonathan Lange
2010-07-29 18:19:17 +01:00
3 changed files with 18 additions and 1 deletions

9
NEWS
View File

@@ -4,6 +4,15 @@ testtools NEWS
NEXT
~~~~
Improvements
------------
* Martin[gz] fixed traceback handling to handle cases where extract_tb returns
a source line of None. Fixes bug #611307.
* Martin[gz] fixed an unicode issue that was causing the tests to fail,
closing bug #604187.
0.9.4
~~~~~

View File

@@ -202,7 +202,8 @@ def _format_exc_info(eclass, evalue, tb, limit=None):
filename.decode(fs_enc, "replace"),
lineno,
name.decode("ascii", "replace"),
line.decode(_get_source_encoding(filename), "replace")))
line and line.decode(
_get_source_encoding(filename), "replace")))
list.extend(traceback.format_list(extracted_list))
else:
list = []

View File

@@ -914,6 +914,13 @@ class TestNonAsciiResults(TestCase):
textoutput = self._test_external_case("self.fail(%s)" % _r(raw))
self.assertIn(self._as_output(text), textoutput)
def test_non_ascii_failure_string_via_exec(self):
"""Assertion via exec can be non-ascii and still gets decoded"""
text, raw = self._get_sample_text(_get_exception_encoding())
textoutput = self._test_external_case(
testline='exec ("self.fail(%s)")' % _r(raw))
self.assertIn(self._as_output(text), textoutput)
def test_control_characters_in_failure_string(self):
"""Control characters in assertions should be escaped"""
textoutput = self._test_external_case("self.fail('\\a\\a\\a')")