From 7b2c8bb833780a6f6a0b5480f65d27248d7b3b53 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Fri, 12 Apr 2013 22:49:19 +0300 Subject: Issue #16658: add missing return to HTTPConnection.send(). Patch by Jeff Knupp --- Lib/test/test_httplib.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'Lib/test/test_httplib.py') diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py index db123dcb56..863e4bc22b 100644 --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -371,6 +371,27 @@ class BasicTest(TestCase): conn.send(io.BytesIO(expected)) self.assertEqual(expected, sock.data) + def test_send_updating_file(self): + def data(): + yield 'data' + yield None + yield 'data_two' + + class UpdatingFile(): + mode = 'r' + d = data() + def read(self, blocksize=-1): + return self.d.__next__() + + expected = b'data' + + conn = client.HTTPConnection('example.com') + sock = FakeSocket("") + conn.sock = sock + conn.send(UpdatingFile()) + self.assertEqual(sock.data, expected) + + def test_send_iter(self): expected = b'GET /foo HTTP/1.1\r\nHost: example.com\r\n' \ b'Accept-Encoding: identity\r\nContent-Length: 11\r\n' \ -- cgit v1.2.1