cdent / wsgi-intercept

Intercept socket connection to wsgi applications for testing
MIT License
42 stars 21 forks source link

support urllib3 > 2 #74

Open cdent opened 7 months ago

cdent commented 7 months ago

A while ago we pinned to urlib3<2 because the interface changed a bit.

It turns out that updating to >2 is harder than expected, seeing errors in tests like

_____________________________________________________________________________ test_https _____________________________________________________________________________
wsgi_intercept/tests/test_urllib3.py:59: in test_https
    resp = http.request(
.tox/py311/lib/python3.11/site-packages/urllib3/_request_methods.py:136: in request
    return self.request_encode_url(
.tox/py311/lib/python3.11/site-packages/urllib3/_request_methods.py:183: in request_encode_url
    return self.urlopen(method, url, **extra_kw)
.tox/py311/lib/python3.11/site-packages/urllib3/poolmanager.py:444: in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
.tox/py311/lib/python3.11/site-packages/urllib3/connectionpool.py:772: in urlopen
    conn = self._get_conn(timeout=pool_timeout)
.tox/py311/lib/python3.11/site-packages/urllib3/connectionpool.py:295: in _get_conn
    return conn or self._new_conn()
.tox/py311/lib/python3.11/site-packages/urllib3/connectionpool.py:1073: in _new_conn
    return self.ConnectionCls(
wsgi_intercept/_urllib3.py:53: in __init__
    WSGI_HTTPSConnection.__init__(self, *args, **kwargs)
wsgi_intercept/__init__.py:584: in __init__
    super().__init__(*args, **kwargs)
/opt/homebrew/Cellar/python@3.11/3.11.7/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py:1425: in __init__
    super(HTTPSConnection, self).__init__(host, port, timeout,
E   TypeError: HTTPSConnection.__init__() takes from 2 to 3 positional arguments but 5 positional arguments (and 1 keyword-only argument) were given

which I've yet to untangle. Because wsgi-intercept does heinous monkey-patching, it's hard to trace all the pieces.

thomasgoirand commented 4 months ago

Hi. This patch set looks like working for me in Debian unstable, though I had to add: kwargs.pop('ssl_context', None) to pass all unit tests.

Hoping this help...