From dd4107f9f036a283337853c832f03f6a761e551e Mon Sep 17 00:00:00 2001
From: Chris Dent <cdent@anticdent.org>
Date: Wed, 20 Mar 2024 21:59:39 +0000
Subject: [PATCH 5/6] pep8 and readme fixes

---
 README.rst                                   |  7 ++++---
 wsgi_intercept/__init__.py                   | 21 +++++++-------------
 wsgi_intercept/_urllib3.py                   |  1 +
 wsgi_intercept/http_client_intercept.py      | 19 +++++-------------
 wsgi_intercept/tests/test_http_client.py     |  5 +----
 wsgi_intercept/tests/test_urllib.py          |  5 +----
 wsgi_intercept/tests/test_urllib3.py         |  2 +-
 wsgi_intercept/tests/test_wsgi_compliance.py |  5 +----
 wsgi_intercept/tests/wsgi_app.py             |  5 -----
 wsgi_intercept/urllib_intercept.py           |  5 +----
 10 files changed, 22 insertions(+), 53 deletions(-)

diff --git a/README.rst b/README.rst
index 750a4e3..3cea98e 100644
--- a/README.rst
+++ b/README.rst
@@ -88,7 +88,7 @@ Packages Intercepted
 Unfortunately each of the HTTP client libraries use their own specific
 mechanism for making HTTP call-outs, so individual implementations are
 needed. At this time there are implementations for ``httplib2``,
-``urllib3``, ``requests``, ``urllib.request``, and ``http.client``
+``urllib3``, ``requests``, ``urllib.request`` and ``http.client``
 in Python 3.
 
 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.
 The Python 2 version of wsgi-intercept was the result. Kumar McMillan
 later took over maintenance.
 
-The current version is tested with Python 3.7-3.12, and pypy3. It was assembled
-by `Chris Dent`_. Testing and documentation improvements from `Sasha Hart`_.
+The current version is tested with Python 3.7-3.12, and pypy3.  It was
+assembled by `Chris Dent`_. Testing and documentation improvements from
+`Sasha Hart`_.
 
 .. _"best Web testing framework":
      http://blog.ianbicking.org/best-of-the-web-app-test-frameworks.html
diff --git a/wsgi_intercept/__init__.py b/wsgi_intercept/__init__.py
index 3592751..c32ce1e 100644
--- a/wsgi_intercept/__init__.py
+++ b/wsgi_intercept/__init__.py
@@ -13,8 +13,8 @@
 Supported Libaries
 ==================
 
-``wsgi_intercept`` works with a variety of HTTP clients in Python 2.7,
-3.7 and beyond, and in pypy.
+``wsgi_intercept`` works with a variety of HTTP clients in Python 3.7
+and beyond, and in pypy.
 
 * urllib2
 * urllib.request
@@ -22,7 +22,7 @@
 * http.client
 * httplib2
 * requests
-* urllib3 (<2.0.0, urllib3 2 support is in progress)
+* urllib3
 
 How Does It Work?
 =================
@@ -88,14 +88,9 @@ def load_app():
 Unfortunately each of the HTTP client libraries use their own specific
 mechanism for making HTTP call-outs, so individual implementations are
 needed. At this time there are implementations for ``httplib2``,
-``urllib3`` (<2.0.0) and ``requests`` in both Python 2 and 3, ``urllib2`` and
-``httplib`` in Python 2 and ``urllib.request`` and ``http.client``
+``urllib3``, ``requests``, ``urllib.request`` and ``http.client``
 in Python 3.
 
-If you are using Python 2 and need support for a different HTTP
-client, require a version of ``wsgi_intercept<0.6``. Earlier versions
-include support for ``webtest``, ``webunit`` and ``zope.testbrowser``.
-
 The best way to figure out how to use interception is to inspect
 `the tests`_. More comprehensive documentation available upon
 request.
@@ -115,9 +110,9 @@ def load_app():
 The Python 2 version of wsgi-intercept was the result. Kumar McMillan
 later took over maintenance.
 
-The current version is tested with Python 2.7, 3.5-3.11, and pypy and pypy3.
-It was assembled by `Chris Dent`_. Testing and documentation improvements
-from `Sasha Hart`_.
+The current version is tested with Python 3.7-3.12, and pypy3.  It was
+assembled by `Chris Dent`_. Testing and documentation improvements from
+`Sasha Hart`_.
 
 .. _"best Web testing framework":
      http://blog.ianbicking.org/best-of-the-web-app-test-frameworks.html
@@ -546,7 +541,6 @@ def __init__(self, *args, **kwargs):
                 args = args[0:2]
             super().__init__(*args, **kwargs)
 
-
     def get_app(self, host, port):
         """
         Return the app object for the given (host, port).
@@ -600,7 +594,6 @@ class WSGI_HTTPSConnection(HTTPSConnection, WSGI_HTTPConnection):
     application object.
     """
 
-
     def get_app(self, host, port):
         """
         Return the app object for the given (host, port).
diff --git a/wsgi_intercept/_urllib3.py b/wsgi_intercept/_urllib3.py
index a67bda0..c6b82c1 100644
--- a/wsgi_intercept/_urllib3.py
+++ b/wsgi_intercept/_urllib3.py
@@ -27,6 +27,7 @@
     'ssl_maximum_version',
 ]
 
+
 def make_urllib3_override(HTTPConnectionPool, HTTPSConnectionPool,
                           HTTPConnection, HTTPSConnection):
 
diff --git a/wsgi_intercept/http_client_intercept.py b/wsgi_intercept/http_client_intercept.py
index 56d930c..7f86b0b 100644
--- a/wsgi_intercept/http_client_intercept.py
+++ b/wsgi_intercept/http_client_intercept.py
@@ -1,23 +1,14 @@
 """Intercept HTTP connections that use httplib (Py2) or http.client (Py3).
 """
 
-try:
-    import http.client as http_lib
-except ImportError:
-    import httplib as http_lib
+import http.client as http_lib
 
 from . import WSGI_HTTPConnection, WSGI_HTTPSConnection
 
-try:
-    from http.client import (
-            HTTPConnection as OriginalHTTPConnection,
-            HTTPSConnection as OriginalHTTPSConnection
-    )
-except ImportError:
-    from httplib import (
-            HTTPConnection as OriginalHTTPConnection,
-            HTTPSConnection as OriginalHTTPSConnection
-    )
+from http.client import (
+        HTTPConnection as OriginalHTTPConnection,
+        HTTPSConnection as OriginalHTTPSConnection
+)
 
 
 class HTTP_WSGIInterceptor(WSGI_HTTPConnection, http_lib.HTTPConnection):
diff --git a/wsgi_intercept/tests/test_http_client.py b/wsgi_intercept/tests/test_http_client.py
index f33f4c7..d2f9a96 100644
--- a/wsgi_intercept/tests/test_http_client.py
+++ b/wsgi_intercept/tests/test_http_client.py
@@ -2,10 +2,7 @@
 from wsgi_intercept import http_client_intercept, WSGIAppError
 from . import wsgi_app
 from .install import installer_class, skipnetwork
-try:
-    import http.client as http_lib
-except ImportError:
-    import httplib as http_lib
+import http.client as http_lib
 
 HOST = 'some_hopefully_nonexistant_domain'
 
diff --git a/wsgi_intercept/tests/test_urllib.py b/wsgi_intercept/tests/test_urllib.py
index 9b1df03..ba9a486 100644
--- a/wsgi_intercept/tests/test_urllib.py
+++ b/wsgi_intercept/tests/test_urllib.py
@@ -3,10 +3,7 @@
 from wsgi_intercept import urllib_intercept, WSGIAppError
 from . import wsgi_app
 from .install import installer_class, skipnetwork
-try:
-    import urllib.request as url_lib
-except ImportError:
-    import urllib2 as url_lib
+import urllib.request as url_lib
 
 HOST = 'some_hopefully_nonexistant_domain'
 
diff --git a/wsgi_intercept/tests/test_urllib3.py b/wsgi_intercept/tests/test_urllib3.py
index b2a7185..d99b929 100644
--- a/wsgi_intercept/tests/test_urllib3.py
+++ b/wsgi_intercept/tests/test_urllib3.py
@@ -54,7 +54,7 @@ def test_proxy_handling():
     del os.environ['http_proxy']
 
 
-def test_https_meo():
+def test_https():
     with InstalledApp(wsgi_app.simple_app, host=HOST, port=443) as app:
         resp = http.request(
             'GET', 'https://some_hopefully_nonexistant_domain:443/')
diff --git a/wsgi_intercept/tests/test_wsgi_compliance.py b/wsgi_intercept/tests/test_wsgi_compliance.py
index 39ee12b..89f73d2 100644
--- a/wsgi_intercept/tests/test_wsgi_compliance.py
+++ b/wsgi_intercept/tests/test_wsgi_compliance.py
@@ -1,9 +1,6 @@
 import sys
 import pytest
-try:
-    from urllib.parse import unquote
-except ImportError:
-    from urllib import unquote
+from urllib.parse import unquote
 from wsgi_intercept import httplib2_intercept
 from . import wsgi_app
 from .install import installer_class
diff --git a/wsgi_intercept/tests/wsgi_app.py b/wsgi_intercept/tests/wsgi_app.py
index 9761bbb..0c573dc 100644
--- a/wsgi_intercept/tests/wsgi_app.py
+++ b/wsgi_intercept/tests/wsgi_app.py
@@ -4,11 +4,6 @@
 
 from pprint import pformat
 
-try:
-    bytes
-except ImportError:
-    bytes = str
-
 
 def simple_app(environ, start_response):
     """Simplest possible application object"""
diff --git a/wsgi_intercept/urllib_intercept.py b/wsgi_intercept/urllib_intercept.py
index 2454d5c..fa0697c 100644
--- a/wsgi_intercept/urllib_intercept.py
+++ b/wsgi_intercept/urllib_intercept.py
@@ -4,10 +4,7 @@
 
 import os
 
-try:
-    import urllib.request as url_lib
-except ImportError:
-    import urllib2 as url_lib
+import urllib.request as url_lib
 
 from . import WSGI_HTTPConnection, WSGI_HTTPSConnection
 

