@@ -64,27 +64,31 @@ def test_client_certificates(self):
6464
6565 def test_HTTPConnection_with_missing_certs (self ):
6666 # Clear any prevously created global context
67+ backup_context = hyper .tls ._context
6768 hyper .tls ._context = None
6869 backup_cert_loc = hyper .tls .cert_loc
6970 hyper .tls .cert_loc = MISSING_PEM_FILE
7071
7172 succeeded = False
7273 threwExpectedException = False
7374 try :
74- hyper .HTTP20Connection ('http2bin.org' , 443 )
75+ conn = hyper .HTTP20Connection ('http2bin.org' , 443 )
76+ conn .request ('GET' , '/' , None , {})
7577 succeeded = True
7678 except hyper .common .exceptions .MissingCertFile :
7779 threwExpectedException = True
7880 except :
7981 pass
8082
8183 hyper .tls .cert_loc = backup_cert_loc
84+ hyper .tls ._context = backup_context
8285
8386 assert not succeeded
8487 assert threwExpectedException
8588
8689 def test_HTTPConnection_with_missing_certs_and_custom_context (self ):
8790 # Clear any prevously created global context
91+ backup_context = hyper .tls ._context
8892 hyper .tls ._context = None
8993 backup_cert_loc = hyper .tls .cert_loc
9094 hyper .tls .cert_loc = MISSING_PEM_FILE
@@ -97,8 +101,10 @@ def test_HTTPConnection_with_missing_certs_and_custom_context(self):
97101 context .options |= ssl .OP_NO_COMPRESSION
98102
99103 conn = hyper .HTTP20Connection ('http2bin.org' , 443 , ssl_context = context )
104+ conn .request ('GET' , '/' , None , {})
100105
101106 hyper .tls .cert_loc = backup_cert_loc
107+ hyper .tls ._context = backup_context
102108
103109 assert conn .ssl_context .check_hostname
104110 assert conn .ssl_context .verify_mode == ssl .CERT_REQUIRED
0 commit comments