Skip to content

Commit dd4107f

Browse files
committed
pep8 and readme fixes
1 parent 8c64076 commit dd4107f

10 files changed

+22
-53
lines changed

README.rst

+4-3
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Packages Intercepted
8888
Unfortunately each of the HTTP client libraries use their own specific
8989
mechanism for making HTTP call-outs, so individual implementations are
9090
needed. At this time there are implementations for ``httplib2``,
91-
``urllib3``, ``requests``, ``urllib.request``, and ``http.client``
91+
``urllib3``, ``requests``, ``urllib.request`` and ``http.client``
9292
in Python 3.
9393

9494
The best way to figure out how to use interception is to inspect
@@ -110,8 +110,9 @@ it into all of the *other* Python Web testing frameworks.
110110
The Python 2 version of wsgi-intercept was the result. Kumar McMillan
111111
later took over maintenance.
112112

113-
The current version is tested with Python 3.7-3.12, and pypy3. It was assembled
114-
by `Chris Dent`_. Testing and documentation improvements from `Sasha Hart`_.
113+
The current version is tested with Python 3.7-3.12, and pypy3. It was
114+
assembled by `Chris Dent`_. Testing and documentation improvements from
115+
`Sasha Hart`_.
115116

116117
.. _"best Web testing framework":
117118
http://blog.ianbicking.org/best-of-the-web-app-test-frameworks.html

wsgi_intercept/__init__.py

+7-14
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
Supported Libaries
1414
==================
1515
16-
``wsgi_intercept`` works with a variety of HTTP clients in Python 2.7,
17-
3.7 and beyond, and in pypy.
16+
``wsgi_intercept`` works with a variety of HTTP clients in Python 3.7
17+
and beyond, and in pypy.
1818
1919
* urllib2
2020
* urllib.request
2121
* httplib
2222
* http.client
2323
* httplib2
2424
* requests
25-
* urllib3 (<2.0.0, urllib3 2 support is in progress)
25+
* urllib3
2626
2727
How Does It Work?
2828
=================
@@ -88,14 +88,9 @@ def load_app():
8888
Unfortunately each of the HTTP client libraries use their own specific
8989
mechanism for making HTTP call-outs, so individual implementations are
9090
needed. At this time there are implementations for ``httplib2``,
91-
``urllib3`` (<2.0.0) and ``requests`` in both Python 2 and 3, ``urllib2`` and
92-
``httplib`` in Python 2 and ``urllib.request`` and ``http.client``
91+
``urllib3``, ``requests``, ``urllib.request`` and ``http.client``
9392
in Python 3.
9493
95-
If you are using Python 2 and need support for a different HTTP
96-
client, require a version of ``wsgi_intercept<0.6``. Earlier versions
97-
include support for ``webtest``, ``webunit`` and ``zope.testbrowser``.
98-
9994
The best way to figure out how to use interception is to inspect
10095
`the tests`_. More comprehensive documentation available upon
10196
request.
@@ -115,9 +110,9 @@ def load_app():
115110
The Python 2 version of wsgi-intercept was the result. Kumar McMillan
116111
later took over maintenance.
117112
118-
The current version is tested with Python 2.7, 3.5-3.11, and pypy and pypy3.
119-
It was assembled by `Chris Dent`_. Testing and documentation improvements
120-
from `Sasha Hart`_.
113+
The current version is tested with Python 3.7-3.12, and pypy3. It was
114+
assembled by `Chris Dent`_. Testing and documentation improvements from
115+
`Sasha Hart`_.
121116
122117
.. _"best Web testing framework":
123118
http://blog.ianbicking.org/best-of-the-web-app-test-frameworks.html
@@ -546,7 +541,6 @@ def __init__(self, *args, **kwargs):
546541
args = args[0:2]
547542
super().__init__(*args, **kwargs)
548543

549-
550544
def get_app(self, host, port):
551545
"""
552546
Return the app object for the given (host, port).
@@ -600,7 +594,6 @@ class WSGI_HTTPSConnection(HTTPSConnection, WSGI_HTTPConnection):
600594
application object.
601595
"""
602596

603-
604597
def get_app(self, host, port):
605598
"""
606599
Return the app object for the given (host, port).

wsgi_intercept/_urllib3.py

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
'ssl_maximum_version',
2828
]
2929

30+
3031
def make_urllib3_override(HTTPConnectionPool, HTTPSConnectionPool,
3132
HTTPConnection, HTTPSConnection):
3233

wsgi_intercept/http_client_intercept.py

+5-14
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
11
"""Intercept HTTP connections that use httplib (Py2) or http.client (Py3).
22
"""
33

4-
try:
5-
import http.client as http_lib
6-
except ImportError:
7-
import httplib as http_lib
4+
import http.client as http_lib
85

96
from . import WSGI_HTTPConnection, WSGI_HTTPSConnection
107

11-
try:
12-
from http.client import (
13-
HTTPConnection as OriginalHTTPConnection,
14-
HTTPSConnection as OriginalHTTPSConnection
15-
)
16-
except ImportError:
17-
from httplib import (
18-
HTTPConnection as OriginalHTTPConnection,
19-
HTTPSConnection as OriginalHTTPSConnection
20-
)
8+
from http.client import (
9+
HTTPConnection as OriginalHTTPConnection,
10+
HTTPSConnection as OriginalHTTPSConnection
11+
)
2112

2213

2314
class HTTP_WSGIInterceptor(WSGI_HTTPConnection, http_lib.HTTPConnection):

wsgi_intercept/tests/test_http_client.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
from wsgi_intercept import http_client_intercept, WSGIAppError
33
from . import wsgi_app
44
from .install import installer_class, skipnetwork
5-
try:
6-
import http.client as http_lib
7-
except ImportError:
8-
import httplib as http_lib
5+
import http.client as http_lib
96

107
HOST = 'some_hopefully_nonexistant_domain'
118

wsgi_intercept/tests/test_urllib.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
from wsgi_intercept import urllib_intercept, WSGIAppError
44
from . import wsgi_app
55
from .install import installer_class, skipnetwork
6-
try:
7-
import urllib.request as url_lib
8-
except ImportError:
9-
import urllib2 as url_lib
6+
import urllib.request as url_lib
107

118
HOST = 'some_hopefully_nonexistant_domain'
129

wsgi_intercept/tests/test_urllib3.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def test_proxy_handling():
5454
del os.environ['http_proxy']
5555

5656

57-
def test_https_meo():
57+
def test_https():
5858
with InstalledApp(wsgi_app.simple_app, host=HOST, port=443) as app:
5959
resp = http.request(
6060
'GET', 'https://some_hopefully_nonexistant_domain:443/')

wsgi_intercept/tests/test_wsgi_compliance.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import sys
22
import pytest
3-
try:
4-
from urllib.parse import unquote
5-
except ImportError:
6-
from urllib import unquote
3+
from urllib.parse import unquote
74
from wsgi_intercept import httplib2_intercept
85
from . import wsgi_app
96
from .install import installer_class

wsgi_intercept/tests/wsgi_app.py

-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44

55
from pprint import pformat
66

7-
try:
8-
bytes
9-
except ImportError:
10-
bytes = str
11-
127

138
def simple_app(environ, start_response):
149
"""Simplest possible application object"""

wsgi_intercept/urllib_intercept.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44

55
import os
66

7-
try:
8-
import urllib.request as url_lib
9-
except ImportError:
10-
import urllib2 as url_lib
7+
import urllib.request as url_lib
118

129
from . import WSGI_HTTPConnection, WSGI_HTTPSConnection
1310

0 commit comments

Comments
 (0)