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
diff --git a/lib/lp/services/messages/tests/test_message.py b/lib/lp/services/messages/tests/test_message.py
index 6c8528b..eb23342 100644
--- a/lib/lp/services/messages/tests/test_message.py
+++ b/lib/lp/services/messages/tests/test_message.py
@@ -12,6 +12,7 @@ from email.utils import (
12 make_msgid,12 make_msgid,
13 )13 )
1414
15import six
15import transaction16import transaction
1617
17from lp.services.messages.model.message import MessageSet18from lp.services.messages.model.message import MessageSet
@@ -27,7 +28,12 @@ class TestMessageSet(TestCaseWithFactory):
2728
28 layer = LaunchpadFunctionalLayer29 layer = LaunchpadFunctionalLayer
2930
30 high_characters = ''.join(chr(c) for c in range(128, 256))31 # Stick to printable non-whitespace characters from ISO-8859-1 to avoid
32 # confusion. (In particular, '\x85' and '\xa0' are whitespace
33 # characters according to Unicode but not according to ASCII, and this
34 # would otherwise result in different test output between Python 2 and
35 # 3.)
36 high_characters = b''.join(six.int2byte(c) for c in range(161, 256))
3137
32 def setUp(self):38 def setUp(self):
33 super(TestMessageSet, self).setUp()39 super(TestMessageSet, self).setUp()
@@ -72,7 +78,7 @@ class TestMessageSet(TestCaseWithFactory):
72 self.assertEqual('text/x-diff', diff.blob.mimetype)78 self.assertEqual('text/x-diff', diff.blob.mimetype)
73 # Need to commit in order to read back out of the librarian.79 # Need to commit in order to read back out of the librarian.
74 transaction.commit()80 transaction.commit()
75 self.assertEqual('This is the diff, honest.', diff.blob.read())81 self.assertEqual(b'This is the diff, honest.', diff.blob.read())
7682
77 def test_fromEmail_strips_attachment_paths(self):83 def test_fromEmail_strips_attachment_paths(self):
78 # Build a simple multipart message with a plain text first part84 # Build a simple multipart message with a plain text first part
@@ -86,7 +92,7 @@ class TestMessageSet(TestCaseWithFactory):
86 self.assertEqual('text/x-diff', diff.blob.mimetype)92 self.assertEqual('text/x-diff', diff.blob.mimetype)
87 # Need to commit in order to read back out of the librarian.93 # Need to commit in order to read back out of the librarian.
88 transaction.commit()94 transaction.commit()
89 self.assertEqual('This is the diff, honest.', diff.blob.read())95 self.assertEqual(b'This is the diff, honest.', diff.blob.read())
9096
91 def test_fromEmail_always_creates(self):97 def test_fromEmail_always_creates(self):
92 """Even when messages are identical, fromEmail creates a new one."""98 """Even when messages are identical, fromEmail creates a new one."""
@@ -152,7 +158,7 @@ class TestMessageSet(TestCaseWithFactory):
152158
153 def test_decode_unknown_ascii(self):159 def test_decode_unknown_ascii(self):
154 """Test decode with ascii characters in an unknown encoding."""160 """Test decode with ascii characters in an unknown encoding."""
155 result = MessageSet.decode('abcde', 'booga')161 result = MessageSet.decode(b'abcde', 'booga')
156 self.assertEqual(u'abcde', result)162 self.assertEqual(u'abcde', result)
157163
158 def test_decode_unknown_high_characters(self):164 def test_decode_unknown_high_characters(self):

Subscribers

People subscribed via source and target branches

to status/vote changes: