Don't use six when testing httplib
Otherwise monkeypatching get confused and will not work and the tests will fail. An effort was made to use the six http_client always (both in tests and the interceptor) but this led to infinite recursion, so going for the lame fix here. The functionality has always worked (as long as six wasn't involved) this is just getting things working in tests.
This commit is contained in:
@@ -11,7 +11,11 @@ import py.test
|
||||
import requests
|
||||
import urllib3
|
||||
from httplib2 import Http, ServerNotFoundError
|
||||
from six.moves import http_client
|
||||
# don't use six as the monkey patching gets confused
|
||||
try:
|
||||
import http.client as http_client
|
||||
except ImportError:
|
||||
import httplib as http_client
|
||||
from six.moves.urllib.request import urlopen
|
||||
from six.moves.urllib.error import URLError
|
||||
|
||||
|
||||
@@ -19,16 +19,13 @@ except ImportError:
|
||||
HTTPSConnection as OriginalHTTPSConnection
|
||||
)
|
||||
|
||||
HTTPInterceptorMixin = WSGI_HTTPConnection
|
||||
HTTPSInterceptorMixin = WSGI_HTTPSConnection
|
||||
|
||||
|
||||
class HTTP_WSGIInterceptor(HTTPInterceptorMixin, http_lib.HTTPConnection):
|
||||
class HTTP_WSGIInterceptor(WSGI_HTTPConnection, http_lib.HTTPConnection):
|
||||
pass
|
||||
|
||||
|
||||
class HTTPS_WSGIInterceptor(HTTPSInterceptorMixin, http_lib.HTTPSConnection,
|
||||
HTTP_WSGIInterceptor):
|
||||
class HTTPS_WSGIInterceptor(WSGI_HTTPSConnection, http_lib.HTTPSConnection,
|
||||
HTTP_WSGIInterceptor):
|
||||
|
||||
def __init__(self, host, **kwargs):
|
||||
self.host = host
|
||||
|
||||
Reference in New Issue
Block a user