Merge ~cjwatson/launchpad:py3-test-layers-functional-bytesio into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 9b21010615557e11922abbf3a0f3e22d11dddfd9
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:py3-test-layers-functional-bytesio
Merge into: launchpad:master
Diff against target: 83 lines (+11/-11)
1 file modified
lib/lp/testing/tests/test_layers_functional.py (+11/-11)
Reviewer Review Type Date Requested Status
Ioana Lasc (community) Approve
Review via email: mp+392080@code.launchpad.net

Commit message

Port test_layers_functional to io.BytesIO

To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/testing/tests/test_layers_functional.py b/lib/lp/testing/tests/test_layers_functional.py
2index bc1b103..987a935 100644
3--- a/lib/lp/testing/tests/test_layers_functional.py
4+++ b/lib/lp/testing/tests/test_layers_functional.py
5@@ -11,7 +11,7 @@ to confirm that the environment hasn't been corrupted by tests
6
7 __metaclass__ = type
8
9-from cStringIO import StringIO
10+import io
11 import os
12 import signal
13 import uuid
14@@ -218,10 +218,10 @@ class BaseTestCase(TestCase):
15 and self.want_component_architecture
16 )
17 client = LibrarianClient()
18- data = 'Whatever'
19+ data = b'Whatever'
20 try:
21 client.addFile(
22- 'foo.txt', len(data), StringIO(data), 'text/plain'
23+ 'foo.txt', len(data), io.BytesIO(data), 'text/plain'
24 )
25 except UploadFailed:
26 self.assertFalse(
27@@ -297,9 +297,9 @@ class LibrarianTestCase(BaseTestCase):
28 # We can test this using remoteAddFile (it does not need the CA
29 # loaded)
30 client = LibrarianClient()
31- data = 'This is a test'
32+ data = b'This is a test'
33 client.remoteAddFile(
34- 'foo.txt', len(data), StringIO(data), 'text/plain')
35+ 'foo.txt', len(data), io.BytesIO(data), 'text/plain')
36
37
38 class LibrarianLayerTest(TestCase, TestWithFixtures):
39@@ -336,7 +336,7 @@ class LibrarianResetTestCase(TestCase):
40 """
41 layer = LibrarianLayer
42
43- sample_data = 'This is a test'
44+ sample_data = b'This is a test'
45
46 def test_librarian_is_reset(self):
47 # Add a file. We use remoteAddFile because it does not need the CA
48@@ -344,7 +344,7 @@ class LibrarianResetTestCase(TestCase):
49 client = LibrarianClient()
50 LibrarianTestCase.url = client.remoteAddFile(
51 self.sample_data, len(self.sample_data),
52- StringIO(self.sample_data), 'text/plain'
53+ io.BytesIO(self.sample_data), 'text/plain'
54 )
55 self.assertEqual(
56 urlopen(LibrarianTestCase.url).read(), self.sample_data
57@@ -362,9 +362,9 @@ class LibrarianHideTestCase(TestCase):
58 def testHideLibrarian(self):
59 # First perform a successful upload:
60 client = LibrarianClient()
61- data = 'foo'
62+ data = b'foo'
63 client.remoteAddFile(
64- 'foo', len(data), StringIO(data), 'text/plain')
65+ 'foo', len(data), io.BytesIO(data), 'text/plain')
66 # The database was committed to, but not by this process, so we need
67 # to ensure that it is fully torn down and recreated.
68 DatabaseLayer.force_dirty_database()
69@@ -372,12 +372,12 @@ class LibrarianHideTestCase(TestCase):
70 # Hide the librarian, and show that the upload fails:
71 LibrarianLayer.hide()
72 self.assertRaises(UploadFailed, client.remoteAddFile,
73- 'foo', len(data), StringIO(data), 'text/plain')
74+ b'foo', len(data), io.BytesIO(data), 'text/plain')
75
76 # Reveal the librarian again, allowing uploads:
77 LibrarianLayer.reveal()
78 client.remoteAddFile(
79- 'foo', len(data), StringIO(data), 'text/plain')
80+ b'foo', len(data), io.BytesIO(data), 'text/plain')
81
82
83 class RabbitMQTestCase(BaseTestCase):

Subscribers

People subscribed via source and target branches

to status/vote changes: