SSLContext was added in Python 2.7.9

This commit is contained in:
Briehan Lombaard 2018-05-16 14:21:19 +02:00 committed by David Lord
parent a35a97e49d
commit a913b4dafd
No known key found for this signature in database
GPG Key ID: 7A1C87E3F5BC42A8
2 changed files with 4 additions and 4 deletions

View File

@ -670,7 +670,7 @@ class CertParamType(click.ParamType):
obj = import_string(value, silent=True)
if sys.version_info < (2, 7):
if sys.version_info < (2, 7, 9):
if obj:
return obj
else:
@ -687,7 +687,7 @@ def _validate_key(ctx, param, value):
cert = ctx.params.get('cert')
is_adhoc = cert == 'adhoc'
if sys.version_info < (2, 7):
if sys.version_info < (2, 7, 9):
is_context = cert and not isinstance(cert, (text_type, bytes))
else:
is_context = isinstance(cert, ssl.SSLContext)

View File

@ -521,12 +521,12 @@ def test_run_cert_import(monkeypatch):
run_command.make_context('run', ['--cert', 'not_here'])
# not an SSLContext
if sys.version_info >= (2, 7):
if sys.version_info >= (2, 7, 9):
with pytest.raises(click.BadParameter):
run_command.make_context('run', ['--cert', 'flask'])
# SSLContext
if sys.version_info < (2, 7):
if sys.version_info < (2, 7, 9):
ssl_context = object()
else:
ssl_context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)