Merge lp:~mars/launchpad/fix-ec2test-utf-in-devel into lp:launchpad

Proposed by Māris Fogels
Status: Superseded
Proposed branch: lp:~mars/launchpad/fix-ec2test-utf-in-devel
Merge into: lp:launchpad
Diff against target: 29 lines (+7/-4)
1 file modified
lib/devscripts/ec2test/tests/test_remote.py (+7/-4)
To merge this branch: bzr merge lp:~mars/launchpad/fix-ec2test-utf-in-devel
Reviewer Review Type Date Requested Status
Leonard Richardson (community) Approve
Jonathan Lange (community) Needs Fixing
Review via email: mp+37760@code.launchpad.net

This proposal has been superseded by a proposal from 2010-10-06.

Description of the change

Hi,

This branch fixes a problem on production-devel and Maverick local developer stations where a test would fail with a UTF-8 decoding error. This patch has already landed in production (see https://code.edge.launchpad.net/~mars/launchpad/fix-ec2test-on-production-devel/+merge/37526).

Maris

To post a comment you must log in.
Revision history for this message
Jonathan Lange (jml) wrote :

Hey Mars,

I think the right approach is to change get_body_text() to use decode=True itself. The point of the helper is to get the text.

Also, strangely, these tests are failing for me in *stable*.

jml

review: Needs Fixing
Revision history for this message
Leonard Richardson (leonardr) :
review: Approve
Revision history for this message
Māris Fogels (mars) wrote :

> Hey Mars,
>
> I think the right approach is to change get_body_text() to use decode=True
> itself. The point of the helper is to get the text.
>
> Also, strangely, these tests are failing for me in *stable*.
>
> jml

I saw this test failing for me in devel/Maverick, and in production-devel/Lucid. I don't know how it spread so widely.

I can fix the helper, but I also found that the reported TestResult changed if I did not do the calculations before the assertEquals() call. If the assertEquals() failed, then *its* TestResult would be used instead, to the great confusion of the developer.

I can change the helper.

Revision history for this message
Māris Fogels (mars) wrote :

Jono, does this fix look better?

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/devscripts/ec2test/tests/test_remote.py'
2--- lib/devscripts/ec2test/tests/test_remote.py 2010-09-20 22:44:49 +0000
3+++ lib/devscripts/ec2test/tests/test_remote.py 2010-10-06 17:12:45 +0000
4@@ -888,7 +888,9 @@
5 """Tests for how we handle the result at the end of the test suite."""
6
7 def get_body_text(self, email):
8- return email.get_payload()[0].get_payload()
9+ # Stringify the utf8-encoded MIME text message part containing the
10+ # test run summary.
11+ return email.get_payload(0).get_payload(decode=True)
12
13 def make_empty_result(self):
14 return TestResult()
15@@ -986,10 +988,11 @@
16 result = self.make_failing_result()
17 logger.got_result(result)
18 [user_message] = log
19+ error_result_string = request.format_result(
20+ result, logger._start_time, logger._end_time)
21 self.assertEqual(
22- request.format_result(
23- result, logger._start_time, logger._end_time),
24- self.get_body_text(user_message).decode('quoted-printable'))
25+ error_result_string,
26+ self.get_body_text(user_message))
27
28 def test_gzip_of_full_log_attached(self):
29 # The full log is attached to the email.