mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 13:19:24 +01:00
Drop dependency on deprecated httplib.HTTP in test framework.
This commit is contained in:
parent
4bf39f773f
commit
54917f581a
25
src/test.py
25
src/test.py
@ -531,19 +531,19 @@ def open_http(url, data=None):
|
|||||||
auth = base64.b64encode(user_passwd).strip()
|
auth = base64.b64encode(user_passwd).strip()
|
||||||
else:
|
else:
|
||||||
auth = None
|
auth = None
|
||||||
h = HTTP(host)
|
c = FakeHTTPConnection(host)
|
||||||
if data is not None:
|
if data is not None:
|
||||||
h.putrequest('POST', selector)
|
c.putrequest('POST', selector)
|
||||||
h.putheader('Content-Type', 'application/x-www-form-urlencoded')
|
c.putheader('Content-Type', 'application/x-www-form-urlencoded')
|
||||||
h.putheader('Content-Length', '%d' % len(data))
|
c.putheader('Content-Length', '%d' % len(data))
|
||||||
else:
|
else:
|
||||||
h.putrequest('GET', selector)
|
c.putrequest('GET', selector)
|
||||||
if proxy_auth: h.putheader('Proxy-Authorization', 'Basic %s' % proxy_auth)
|
if proxy_auth: c.putheader('Proxy-Authorization', 'Basic %s' % proxy_auth)
|
||||||
if auth: h.putheader('Authorization', 'Basic %s' % auth)
|
if auth: c.putheader('Authorization', 'Basic %s' % auth)
|
||||||
if realhost: h.putheader('Host', realhost)
|
if realhost: c.putheader('Host', realhost)
|
||||||
for args in urllib.URLopener().addheaders: h.putheader(*args)
|
for args in urllib.URLopener().addheaders: c.putheader(*args)
|
||||||
h.endheaders()
|
c.endheaders()
|
||||||
return h
|
return c
|
||||||
|
|
||||||
class FakeHTTPConnection(httplib.HTTPConnection):
|
class FakeHTTPConnection(httplib.HTTPConnection):
|
||||||
_data = ''
|
_data = ''
|
||||||
@ -562,9 +562,6 @@ class FakeHTTPConnection(httplib.HTTPConnection):
|
|||||||
#def getresponse(self, *args, **kwargs):
|
#def getresponse(self, *args, **kwargs):
|
||||||
# pass
|
# pass
|
||||||
|
|
||||||
class HTTP(httplib.HTTP):
|
|
||||||
_connection_class = FakeHTTPConnection
|
|
||||||
|
|
||||||
class HTTPPluginTestCase(PluginTestCase):
|
class HTTPPluginTestCase(PluginTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
PluginTestCase.setUp(self, forceSetup=True)
|
PluginTestCase.setUp(self, forceSetup=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user