mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Create http package. #2883.
This commit is contained in:
parent
744c2cd325
commit
2442015af2
50 changed files with 930 additions and 1203 deletions
|
@ -1,7 +1,7 @@
|
|||
"""Regresssion tests for urllib"""
|
||||
|
||||
import urllib
|
||||
import httplib
|
||||
import http.client
|
||||
import io
|
||||
import unittest
|
||||
from test import support
|
||||
|
@ -107,14 +107,14 @@ class urlopen_HttpTests(unittest.TestCase):
|
|||
def readline(self, length=None):
|
||||
if self.closed: return b""
|
||||
return io.BytesIO.readline(self, length)
|
||||
class FakeHTTPConnection(httplib.HTTPConnection):
|
||||
class FakeHTTPConnection(http.client.HTTPConnection):
|
||||
def connect(self):
|
||||
self.sock = FakeSocket(fakedata)
|
||||
self._connection_class = httplib.HTTPConnection
|
||||
httplib.HTTPConnection = FakeHTTPConnection
|
||||
self._connection_class = http.client.HTTPConnection
|
||||
http.client.HTTPConnection = FakeHTTPConnection
|
||||
|
||||
def unfakehttp(self):
|
||||
httplib.HTTPConnection = self._connection_class
|
||||
http.client.HTTPConnection = self._connection_class
|
||||
|
||||
def test_read(self):
|
||||
self.fakehttp(b"Hello!")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue