Cleanup the tests and other code for various versions.

python <= 3.2 doesn't care for for u'' strings but unicode_literals
from __future__ has side effects we don't want.

Other fixes from flake8
This commit is contained in:
Chris Dent
2013-11-01 23:52:21 +00:00
parent 441c4814e4
commit be7599e94a
6 changed files with 11 additions and 14 deletions

View File

@@ -9,4 +9,4 @@ clean:
rm -r *-bundle* || true
test:
py.test -x test
py.test --tb=short -x test

View File

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

View File

@@ -1,4 +1,3 @@
import pytest
try:
import urllib.request as url_lib
except ImportError:

View File

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

View File

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

View File

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