Merge ~cjwatson/launchpad:py3-short-http-response-handling into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 41436ddf9ed956176f7bcb92de5e50c6c84396dd
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:py3-short-http-response-handling
Merge into: launchpad:master
Diff against target: 26 lines (+6/-2)
1 file modified
lib/lp/services/librarian/tests/test_client.py (+6/-2)
Reviewer Review Type Date Requested Status
Cristian Gonzalez (community) Approve
Review via email: mp+396915@code.launchpad.net

Commit message

Adjust tests for different short HTTP response handling 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/librarian/tests/test_client.py b/lib/lp/services/librarian/tests/test_client.py
2index d7f3cba..a9475b2 100644
3--- a/lib/lp/services/librarian/tests/test_client.py
4+++ b/lib/lp/services/librarian/tests/test_client.py
5@@ -20,6 +20,7 @@ from six.moves.urllib.error import (
6 URLError,
7 )
8 from six.moves.urllib.request import urlopen
9+from testtools.testcase import ExpectedException
10 import transaction
11
12 from lp.services.config import config
13@@ -171,8 +172,11 @@ class LibrarianFileWrapperTestCase(TestCase):
14
15 def test_unbounded_read_incorrect_length(self):
16 file = self.makeFile(extra_content_length=1)
17- self.assertEqual(b"abcdef", file.read())
18- self.assertRaises(http_client.IncompleteRead, file.read)
19+ with ExpectedException(http_client.IncompleteRead):
20+ # Python 3 notices the short response on the first read.
21+ self.assertEqual(b"abcdef", file.read())
22+ # Python 2 only notices the short response on the next read.
23+ file.read()
24
25 def test_bounded_read_correct_length(self):
26 file = self.makeFile()

Subscribers

People subscribed via source and target branches

to status/vote changes: