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
=== modified file 'lib/devscripts/ec2test/tests/test_remote.py'
--- lib/devscripts/ec2test/tests/test_remote.py 2010-09-20 22:44:49 +0000
+++ lib/devscripts/ec2test/tests/test_remote.py 2010-10-06 17:12:45 +0000
@@ -888,7 +888,9 @@
888 """Tests for how we handle the result at the end of the test suite."""888 """Tests for how we handle the result at the end of the test suite."""
889889
890 def get_body_text(self, email):890 def get_body_text(self, email):
891 return email.get_payload()[0].get_payload()891 # Stringify the utf8-encoded MIME text message part containing the
892 # test run summary.
893 return email.get_payload(0).get_payload(decode=True)
892894
893 def make_empty_result(self):895 def make_empty_result(self):
894 return TestResult()896 return TestResult()
@@ -986,10 +988,11 @@
986 result = self.make_failing_result()988 result = self.make_failing_result()
987 logger.got_result(result)989 logger.got_result(result)
988 [user_message] = log990 [user_message] = log
991 error_result_string = request.format_result(
992 result, logger._start_time, logger._end_time)
989 self.assertEqual(993 self.assertEqual(
990 request.format_result(994 error_result_string,
991 result, logger._start_time, logger._end_time),995 self.get_body_text(user_message))
992 self.get_body_text(user_message).decode('quoted-printable'))
993996
994 def test_gzip_of_full_log_attached(self):997 def test_gzip_of_full_log_attached(self):
995 # The full log is attached to the email.998 # The full log is attached to the email.