← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3-bug-attachment-tests into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-bug-attachment-tests into launchpad:master.

Commit message:
Fix attachment handling in xx-bug.txt for Python 3

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/398388

lazr.restful >= 1.0.0 requires us to be more careful about the type of the `data` argument.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-bug-attachment-tests into launchpad:master.
diff --git a/lib/lp/bugs/stories/webservice/xx-bug.txt b/lib/lp/bugs/stories/webservice/xx-bug.txt
index 20e11c6..04480a5 100644
--- a/lib/lp/bugs/stories/webservice/xx-bug.txt
+++ b/lib/lp/bugs/stories/webservice/xx-bug.txt
@@ -1263,10 +1263,11 @@ Bug 1 has no attachments:
 
 An attachment can be added to the bug:
 
+    >>> import io
     >>> response = webservice.named_post(
     ...     bug_one['self_link'], 'addAttachment',
-    ...     data=b"12345", filename="numbers.txt", content_type='foo/bar',
-    ...     comment="The numbers you asked for.")
+    ...     data=io.BytesIO(b"12345"), filename="numbers.txt",
+    ...     content_type='foo/bar', comment="The numbers you asked for.")
     >>> print(response)
     HTTP/1.1 201 Created...
     Content-Length: 0
@@ -1333,7 +1334,7 @@ we must follow to download the data.
     >>> conn.headers['Content-Length']
     '5'
 
-    >>> data
+    >>> six.ensure_str(data)
     '12345'
 
 We can see that a message was created and linked to our
@@ -1378,7 +1379,7 @@ Once an attachment is uploaded, it is not possible to change it.
     ...     data = conn.read()
     ... finally:
     ...     conn.close()
-    >>> data
+    >>> six.ensure_str(data)
     '12345'
 
 But we can remove the attachment altogether.