summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2009-09-29 18:14:09 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2009-09-29 18:14:09 (GMT)
commit530e1aca0590633b06341a375d359cf5fd34d0a6 (patch)
treed07597b1a80d596251fee2ee772ef4346864bce1 /Lib/test
parentd08417182f7045b53c467934dbd36a51f39e7d5b (diff)
downloadcpython-530e1aca0590633b06341a375d359cf5fd34d0a6.zip
cpython-530e1aca0590633b06341a375d359cf5fd34d0a6.tar.gz
cpython-530e1aca0590633b06341a375d359cf5fd34d0a6.tar.bz2
Merged revisions 75134 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r75134 | antoine.pitrou | 2009-09-29 19:48:18 +0200 (mar., 29 sept. 2009) | 4 lines Issue #6790: Make it possible again to pass an `array.array` to `httplib.HTTPConnection.send`. Patch by Kirk McDonald. ........
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_httplib.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py
index 54a2b0e..252834b 100644
--- a/Lib/test/test_httplib.py
+++ b/Lib/test/test_httplib.py
@@ -1,3 +1,4 @@
+import array
import httplib
import StringIO
import socket
@@ -15,7 +16,7 @@ class FakeSocket:
self.data = ''
def sendall(self, data):
- self.data += data
+ self.data += ''.join(data)
def makefile(self, mode, bufsize=None):
if mode != 'r' and mode != 'rb':
@@ -162,6 +163,20 @@ class BasicTest(TestCase):
conn.request('GET', '/foo', body)
self.assertTrue(sock.data.startswith(expected))
+ def test_send(self):
+ expected = 'this is a test this is only a test'
+ conn = httplib.HTTPConnection('example.com')
+ sock = FakeSocket(None)
+ conn.sock = sock
+ conn.send(expected)
+ self.assertEquals(expected, sock.data)
+ sock.data = ''
+ conn.send(array.array('c', expected))
+ self.assertEquals(expected, sock.data)
+ sock.data = ''
+ conn.send(StringIO.StringIO(expected))
+ self.assertEquals(expected, sock.data)
+
def test_chunked(self):
chunked_start = (
'HTTP/1.1 200 OK\r\n'