Merge pull request #1733 from yan12125/py37

Python 3.7 support
This commit is contained in:
Steve Pulec 2018-09-22 16:50:50 -04:00 committed by GitHub
commit 74b7634b95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 4 deletions

View File

@ -8,6 +8,19 @@ python:
env: env:
- TEST_SERVER_MODE=false - TEST_SERVER_MODE=false
- TEST_SERVER_MODE=true - TEST_SERVER_MODE=true
# Due to incomplete Python 3.7 support on Travis CI (
# https://github.com/travis-ci/travis-ci/issues/9815),
# using a matrix is necessary
matrix:
include:
- python: 3.7
env: TEST_SERVER_MODE=false
dist: xenial
sudo: true
- python: 3.7
env: TEST_SERVER_MODE=true
dist: xenial
sudo: true
before_install: before_install:
- export BOTO_CONFIG=/dev/null - export BOTO_CONFIG=/dev/null
install: install:

View File

@ -85,6 +85,7 @@ old_socksocket = None
old_ssl_wrap_socket = None old_ssl_wrap_socket = None
old_sslwrap_simple = None old_sslwrap_simple = None
old_sslsocket = None old_sslsocket = None
old_sslcontext_wrap_socket = None
if PY3: # pragma: no cover if PY3: # pragma: no cover
basestring = (bytes, str) basestring = (bytes, str)
@ -100,6 +101,10 @@ try: # pragma: no cover
if not PY3: if not PY3:
old_sslwrap_simple = ssl.sslwrap_simple old_sslwrap_simple = ssl.sslwrap_simple
old_sslsocket = ssl.SSLSocket old_sslsocket = ssl.SSLSocket
try:
old_sslcontext_wrap_socket = ssl.SSLContext.wrap_socket
except AttributeError:
pass
except ImportError: # pragma: no cover except ImportError: # pragma: no cover
ssl = None ssl = None
@ -281,7 +286,7 @@ class fakesock(object):
return { return {
'notAfter': shift.strftime('%b %d %H:%M:%S GMT'), 'notAfter': shift.strftime('%b %d %H:%M:%S GMT'),
'subjectAltName': ( 'subjectAltName': (
('DNS', '*%s' % self._host), ('DNS', '*.%s' % self._host),
('DNS', self._host), ('DNS', self._host),
('DNS', '*'), ('DNS', '*'),
), ),
@ -772,7 +777,7 @@ class URIMatcher(object):
def __init__(self, uri, entries, match_querystring=False): def __init__(self, uri, entries, match_querystring=False):
self._match_querystring = match_querystring self._match_querystring = match_querystring
if type(uri).__name__ == 'SRE_Pattern': if type(uri).__name__ in ('SRE_Pattern', 'Pattern'):
self.regex = uri self.regex = uri
result = urlsplit(uri.pattern) result = urlsplit(uri.pattern)
if result.scheme == 'https': if result.scheme == 'https':
@ -1012,6 +1017,10 @@ class httpretty(HttpBaseClass):
if ssl: if ssl:
ssl.wrap_socket = old_ssl_wrap_socket ssl.wrap_socket = old_ssl_wrap_socket
ssl.SSLSocket = old_sslsocket ssl.SSLSocket = old_sslsocket
try:
ssl.SSLContext.wrap_socket = old_sslcontext_wrap_socket
except AttributeError:
pass
ssl.__dict__['wrap_socket'] = old_ssl_wrap_socket ssl.__dict__['wrap_socket'] = old_ssl_wrap_socket
ssl.__dict__['SSLSocket'] = old_sslsocket ssl.__dict__['SSLSocket'] = old_sslsocket
@ -1058,6 +1067,14 @@ class httpretty(HttpBaseClass):
ssl.wrap_socket = fake_wrap_socket ssl.wrap_socket = fake_wrap_socket
ssl.SSLSocket = FakeSSLSocket ssl.SSLSocket = FakeSSLSocket
try:
def fake_sslcontext_wrap_socket(cls, *args, **kwargs):
return fake_wrap_socket(*args, **kwargs)
ssl.SSLContext.wrap_socket = fake_sslcontext_wrap_socket
except AttributeError:
pass
ssl.__dict__['wrap_socket'] = fake_wrap_socket ssl.__dict__['wrap_socket'] = fake_wrap_socket
ssl.__dict__['SSLSocket'] = FakeSSLSocket ssl.__dict__['SSLSocket'] = FakeSSLSocket

View File

@ -1,7 +1,7 @@
-r requirements.txt -r requirements.txt
mock mock
nose nose
sure==1.2.24 sure==1.4.11
coverage coverage
flake8==3.5.0 flake8==3.5.0
freezegun freezegun
@ -13,5 +13,5 @@ six>=1.9
prompt-toolkit==1.0.14 prompt-toolkit==1.0.14
click==6.7 click==6.7
inflection==0.3.1 inflection==0.3.1
lxml==4.0.0 lxml==4.2.3
beautifulsoup4==4.6.0 beautifulsoup4==4.6.0