Merge lp:~gz/testtools/no_source_line_611307 into lp:~testtools-committers/testtools/trunk

Proposed by Martin Packman
Status: Merged
Merged at revision: 82
Proposed branch: lp:~gz/testtools/no_source_line_611307
Merge into: lp:~testtools-committers/testtools/trunk
Diff against target: 31 lines (+9/-1)
2 files modified
testtools/compat.py (+2/-1)
testtools/tests/test_testresult.py (+7/-0)
To merge this branch: bzr merge lp:~gz/testtools/no_source_line_611307
Reviewer Review Type Date Requested Status
testtools developers Pending
Review via email: mp+31290@code.launchpad.net

Description of the change

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.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'testtools/compat.py'
2--- testtools/compat.py 2010-06-23 00:32:51 +0000
3+++ testtools/compat.py 2010-07-29 14:11:04 +0000
4@@ -202,7 +202,8 @@
5 filename.decode(fs_enc, "replace"),
6 lineno,
7 name.decode("ascii", "replace"),
8- line.decode(_get_source_encoding(filename), "replace")))
9+ line and line.decode(
10+ _get_source_encoding(filename), "replace")))
11 list.extend(traceback.format_list(extracted_list))
12 else:
13 list = []
14
15=== modified file 'testtools/tests/test_testresult.py'
16--- testtools/tests/test_testresult.py 2010-07-29 13:01:25 +0000
17+++ testtools/tests/test_testresult.py 2010-07-29 14:11:04 +0000
18@@ -914,6 +914,13 @@
19 textoutput = self._test_external_case("self.fail(%s)" % _r(raw))
20 self.assertIn(self._as_output(text), textoutput)
21
22+ def test_non_ascii_failure_string_via_exec(self):
23+ """Assertion via exec can be non-ascii and still gets decoded"""
24+ text, raw = self._get_sample_text(_get_exception_encoding())
25+ textoutput = self._test_external_case(
26+ testline='exec ("self.fail(%s)")' % _r(raw))
27+ self.assertIn(self._as_output(text), textoutput)
28+
29 def test_control_characters_in_failure_string(self):
30 """Control characters in assertions should be escaped"""
31 textoutput = self._test_external_case("self.fail('\\a\\a\\a')")

Subscribers

People subscribed via source and target branches