summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_httplib.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-05-16 15:58:41 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-05-16 15:58:41 (GMT)
commit80573bb90200423a6d1760f87bc9e05b129bd09a (patch)
tree1e0ae2edc1d76b04a792af2bbe9379e52a6d533e /Lib/test/test_httplib.py
parentb70091a8d5014b1c5d8738c17ae801d79dd5392d (diff)
downloadcpython-80573bb90200423a6d1760f87bc9e05b129bd09a.zip
cpython-80573bb90200423a6d1760f87bc9e05b129bd09a.tar.gz
cpython-80573bb90200423a6d1760f87bc9e05b129bd09a.tar.bz2
Issue #15267: HTTPConnection.request() now is compatibile with old-style
classes (such as TemporaryFile). Original patch by Atsuo Ishimoto.
Diffstat (limited to 'Lib/test/test_httplib.py')
-rw-r--r--Lib/test/test_httplib.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py
index fc7c571..dc986a9 100644
--- a/Lib/test/test_httplib.py
+++ b/Lib/test/test_httplib.py
@@ -5,6 +5,7 @@ import StringIO
import socket
import errno
import os
+import tempfile
import unittest
TestCase = unittest.TestCase
@@ -399,6 +400,22 @@ class BasicTest(TestCase):
conn.sock = sock
conn.request('GET', '/foo', body)
self.assertTrue(sock.data.startswith(expected))
+ self.assertIn('def test_send_file', sock.data)
+
+ def test_send_tempfile(self):
+ expected = ('GET /foo HTTP/1.1\r\nHost: example.com\r\n'
+ 'Accept-Encoding: identity\r\nContent-Length: 9\r\n\r\n'
+ 'fake\ndata')
+
+ with tempfile.TemporaryFile() as body:
+ body.write('fake\ndata')
+ body.seek(0)
+
+ conn = httplib.HTTPConnection('example.com')
+ sock = FakeSocket(body)
+ conn.sock = sock
+ conn.request('GET', '/foo', body)
+ self.assertEqual(sock.data, expected)
def test_send(self):
expected = 'this is a test this is only a test'