Merge ~cjwatson/launchpad:py3-test-message into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 6062c0756c38581aec0afa86bb9326813ee8449c
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:py3-test-message
Merge into: launchpad:master
Diff against target: 53 lines (+10/-4)
1 file modified
lib/lp/services/messages/tests/test_message.py (+10/-4)
Reviewer Review Type Date Requested Status
Cristian Gonzalez (community) Approve
Review via email: mp+396324@code.launchpad.net

Commit message

lp.services.messages.tests.test_message: Fix test failures on Python 3

To post a comment you must log in.
Revision history for this message
Cristian Gonzalez (cristiangsp) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/services/messages/tests/test_message.py b/lib/lp/services/messages/tests/test_message.py
2index 6c8528b..eb23342 100644
3--- a/lib/lp/services/messages/tests/test_message.py
4+++ b/lib/lp/services/messages/tests/test_message.py
5@@ -12,6 +12,7 @@ from email.utils import (
6 make_msgid,
7 )
8
9+import six
10 import transaction
11
12 from lp.services.messages.model.message import MessageSet
13@@ -27,7 +28,12 @@ class TestMessageSet(TestCaseWithFactory):
14
15 layer = LaunchpadFunctionalLayer
16
17- high_characters = ''.join(chr(c) for c in range(128, 256))
18+ # Stick to printable non-whitespace characters from ISO-8859-1 to avoid
19+ # confusion. (In particular, '\x85' and '\xa0' are whitespace
20+ # characters according to Unicode but not according to ASCII, and this
21+ # would otherwise result in different test output between Python 2 and
22+ # 3.)
23+ high_characters = b''.join(six.int2byte(c) for c in range(161, 256))
24
25 def setUp(self):
26 super(TestMessageSet, self).setUp()
27@@ -72,7 +78,7 @@ class TestMessageSet(TestCaseWithFactory):
28 self.assertEqual('text/x-diff', diff.blob.mimetype)
29 # Need to commit in order to read back out of the librarian.
30 transaction.commit()
31- self.assertEqual('This is the diff, honest.', diff.blob.read())
32+ self.assertEqual(b'This is the diff, honest.', diff.blob.read())
33
34 def test_fromEmail_strips_attachment_paths(self):
35 # Build a simple multipart message with a plain text first part
36@@ -86,7 +92,7 @@ class TestMessageSet(TestCaseWithFactory):
37 self.assertEqual('text/x-diff', diff.blob.mimetype)
38 # Need to commit in order to read back out of the librarian.
39 transaction.commit()
40- self.assertEqual('This is the diff, honest.', diff.blob.read())
41+ self.assertEqual(b'This is the diff, honest.', diff.blob.read())
42
43 def test_fromEmail_always_creates(self):
44 """Even when messages are identical, fromEmail creates a new one."""
45@@ -152,7 +158,7 @@ class TestMessageSet(TestCaseWithFactory):
46
47 def test_decode_unknown_ascii(self):
48 """Test decode with ascii characters in an unknown encoding."""
49- result = MessageSet.decode('abcde', 'booga')
50+ result = MessageSet.decode(b'abcde', 'booga')
51 self.assertEqual(u'abcde', result)
52
53 def test_decode_unknown_high_characters(self):

Subscribers

People subscribed via source and target branches

to status/vote changes: