diff --git a/Makefile b/Makefile index 6fe216c..d633f2a 100644 --- a/Makefile +++ b/Makefile @@ -9,4 +9,4 @@ clean: rm -r *-bundle* || true test: - py.test -x test + py.test --tb=short -x test diff --git a/test/test_requests.py b/test/test_requests.py index c630e2c..f173816 100644 --- a/test/test_requests.py +++ b/test/test_requests.py @@ -5,7 +5,6 @@ import wsgi_intercept from test import wsgi_app import requests -import sys import py.test @@ -30,7 +29,6 @@ def test_success(): def test_bogus_domain(): install() - resp = requests.get('http://some_hopefully_nonexistant_domain:80/') py.test.raises(ConnectionError, 'requests.get("http://_nonexistant_domain_")') uninstall() diff --git a/test/test_urllib.py b/test/test_urllib.py index 05c045d..ce09af8 100644 --- a/test/test_urllib.py +++ b/test/test_urllib.py @@ -1,4 +1,3 @@ -import pytest try: import urllib.request as url_lib except ImportError: diff --git a/test/test_wsgi_compliance.py b/test/test_wsgi_compliance.py index 576c30e..a306804 100644 --- a/test/test_wsgi_compliance.py +++ b/test/test_wsgi_compliance.py @@ -1,3 +1,5 @@ + +import sys import py.test from wsgi_intercept.httplib2_intercept import install, uninstall import wsgi_intercept @@ -44,6 +46,7 @@ def test_more_interesting(): http_uninstall() + def test_script_name(): http_install() wsgi_intercept.add_wsgi_intercept( @@ -59,10 +62,10 @@ def test_script_name(): http_uninstall() + +@py.test.mark.skipif(sys.version_info[0] == 3 and sys.version_info[1] <= 2, + reason='unicode literals needed for this test') def test_encoding_errors(): - """ - This error is actually happening before we get to wsgi_intercept. - """ http_install() wsgi_intercept.add_wsgi_intercept( 'some_hopefully_nonexistant_domain', 80, diff --git a/wsgi_intercept/__init__.py b/wsgi_intercept/__init__.py index 1196ef9..6bd4f8d 100644 --- a/wsgi_intercept/__init__.py +++ b/wsgi_intercept/__init__.py @@ -477,15 +477,17 @@ class WSGI_HTTPConnection(HTTPConnection): else: HTTPConnection.connect(self) - except Exception as e: + except Exception: if debuglevel: # intercept & print out tracebacks traceback.print_exc() raise + # # WSGI_HTTPSConnection # + class WSGI_HTTPSConnection(HTTPSConnection, WSGI_HTTPConnection): """ Intercept all traffic to certain hosts & redirect into a WSGI @@ -527,7 +529,7 @@ class WSGI_HTTPSConnection(HTTPSConnection, WSGI_HTTPConnection): else: HTTPSConnection.connect(self) - except Exception as e: + except Exception: if debuglevel: # intercept & print out tracebacks traceback.print_exc() raise diff --git a/wsgi_intercept/urllib_intercept.py b/wsgi_intercept/urllib_intercept.py index 6ff6d0b..2be6a7c 100644 --- a/wsgi_intercept/urllib_intercept.py +++ b/wsgi_intercept/urllib_intercept.py @@ -4,11 +4,6 @@ try: except ImportError: import urllib2 as url_lib -try: - from urllib.request import HTTPHandler, HTTPSHandler -except ImportError: - from urllib2 import HTTPHandler, HTTPSHandler - from . import WSGI_HTTPConnection, WSGI_HTTPSConnection