Merge ~cjwatson/launchpad:py3-factory-bytesio into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 5fd2c7402d0b4bde7225838047eecc150f40f542
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:py3-factory-bytesio
Merge into: launchpad:master
Diff against target: 54 lines (+8/-7)
1 file modified
lib/lp/testing/factory.py (+8/-7)
Reviewer Review Type Date Requested Status
Thiago F. Pappacena (community) Approve
Review via email: mp+391444@code.launchpad.net

Commit message

Port lp.testing.factory to BytesIO

To post a comment you must log in.
Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

LGTM

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/factory.py b/lib/lp/testing/factory.py
2index d0314ec..0cb90a9 100644
3--- a/lib/lp/testing/factory.py
4+++ b/lib/lp/testing/factory.py
5@@ -36,7 +36,6 @@ import hashlib
6 from io import BytesIO
7 from itertools import count
8 import os
9-from StringIO import StringIO
10 import sys
11 from textwrap import dedent
12 import types
13@@ -2657,7 +2656,9 @@ class BareLaunchpadObjectFactory(ObjectFactory):
14 if filename is None:
15 filename = self.getUniqueString('filename')
16 if content is None:
17- content = self.getUniqueString()
18+ content = self.getUniqueBytes()
19+ else:
20+ content = six.ensure_binary(content)
21
22 if db_only:
23 # Often we don't actually care if the file exists on disk.
24@@ -2671,7 +2672,7 @@ class BareLaunchpadObjectFactory(ObjectFactory):
25 content=lfc, filename=filename, mimetype=content_type)
26 else:
27 lfa = getUtility(ILibraryFileAliasSet).create(
28- filename, len(content), StringIO(content), content_type,
29+ filename, len(content), BytesIO(content), content_type,
30 expires=expires, restricted=restricted)
31 return lfa
32
33@@ -3537,8 +3538,8 @@ class BareLaunchpadObjectFactory(ObjectFactory):
34
35 def makeMirrorProbeRecord(self, mirror):
36 """Create a probe record for a mirror of a distribution."""
37- log_file = StringIO()
38- log_file.write("Fake probe, nothing useful here.")
39+ log_file = BytesIO()
40+ log_file.write(b"Fake probe, nothing useful here.")
41 log_file.seek(0)
42
43 library_alias = getUtility(ILibraryFileAliasSet).create(
44@@ -4638,8 +4639,8 @@ class BareLaunchpadObjectFactory(ObjectFactory):
45 if filename is None:
46 filename = self.getUniqueString()
47 if content is None:
48- content = self.getUniqueString()
49- fileupload = StringIO(content)
50+ content = self.getUniqueBytes()
51+ fileupload = BytesIO(content)
52 fileupload.filename = filename
53 fileupload.headers = {
54 'Content-Type': 'text/plain; charset=utf-8',

Subscribers

People subscribed via source and target branches

to status/vote changes: