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:
Chris Dent
2016-06-29 13:49:21 -04:00
parent 77b5c04a90
commit d34e64f764
2 changed files with 8 additions and 7 deletions

View File

@@ -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

View File

@@ -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