testtools-dev team mailing list archive
-
testtools-dev team
-
Mailing list archive
-
Message #00001
[Merge] lp:~gz/testtools/no_source_line_611307 into lp:testtools
Martin [gz] has proposed merging lp:~gz/testtools/no_source_line_611307 into lp:testtools.
Requested reviews:
testtools developers (testtools-dev)
Related bugs:
#611307 Unicode tracebacks break when a line is None rather than str
https://bugs.launchpad.net/bugs/611307
Test and fix for brown paper bag issue when the source line in a traceback is None rather than a str. This is the only remaining problem that should block a new release that I know of.
--
https://code.launchpad.net/~gz/testtools/no_source_line_611307/+merge/31290
Your team testtools developers is requested to review the proposed merge of lp:~gz/testtools/no_source_line_611307 into lp:testtools.
=== modified file 'testtools/compat.py'
--- testtools/compat.py 2010-06-23 00:32:51 +0000
+++ testtools/compat.py 2010-07-29 14:11:04 +0000
@@ -202,7 +202,8 @@
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 = []
=== modified file 'testtools/tests/test_testresult.py'
--- testtools/tests/test_testresult.py 2010-07-29 13:01:25 +0000
+++ testtools/tests/test_testresult.py 2010-07-29 14:11:04 +0000
@@ -914,6 +914,13 @@
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')")
Follow ups