← Back to team overview

launchpad-reviewers team mailing list archive

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

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-short-http-response-handling into launchpad:master.

Commit message:
Adjust tests for different short HTTP response handling on Python 3

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/396915
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-short-http-response-handling into launchpad:master.
diff --git a/lib/lp/services/librarian/tests/test_client.py b/lib/lp/services/librarian/tests/test_client.py
index d7f3cba..a9475b2 100644
--- a/lib/lp/services/librarian/tests/test_client.py
+++ b/lib/lp/services/librarian/tests/test_client.py
@@ -20,6 +20,7 @@ from six.moves.urllib.error import (
     URLError,
     )
 from six.moves.urllib.request import urlopen
+from testtools.testcase import ExpectedException
 import transaction
 
 from lp.services.config import config
@@ -171,8 +172,11 @@ class LibrarianFileWrapperTestCase(TestCase):
 
     def test_unbounded_read_incorrect_length(self):
         file = self.makeFile(extra_content_length=1)
-        self.assertEqual(b"abcdef", file.read())
-        self.assertRaises(http_client.IncompleteRead, file.read)
+        with ExpectedException(http_client.IncompleteRead):
+            # Python 3 notices the short response on the first read.
+            self.assertEqual(b"abcdef", file.read())
+            # Python 2 only notices the short response on the next read.
+            file.read()
 
     def test_bounded_read_correct_length(self):
         file = self.makeFile()