@@ -150,6 +150,9 @@ def data_file(*name):
150
150
OP_ENABLE_MIDDLEBOX_COMPAT = getattr (ssl , "OP_ENABLE_MIDDLEBOX_COMPAT" , 0 )
151
151
OP_IGNORE_UNEXPECTED_EOF = getattr (ssl , "OP_IGNORE_UNEXPECTED_EOF" , 0 )
152
152
153
+ # *_TIMEOUT constants are available in test.support in 3.9+
154
+ SHORT_TIMEOUT = 30.0
155
+
153
156
# Ubuntu has patched OpenSSL and changed behavior of security level 2
154
157
# see https://bugs.python.org/issue41561#msg389003
155
158
def is_ubuntu ():
@@ -4835,7 +4838,7 @@ def __init__(self, *, name, call_after_accept, timeout=None):
4835
4838
self .listener = None # set by .start()
4836
4839
self .port = None # set by .start()
4837
4840
if timeout is None :
4838
- self .timeout = support . SHORT_TIMEOUT
4841
+ self .timeout = SHORT_TIMEOUT
4839
4842
else :
4840
4843
self .timeout = timeout
4841
4844
super ().__init__ (name = name )
@@ -4917,7 +4920,7 @@ def test_preauth_data_to_tls_server(self):
4917
4920
4918
4921
def call_after_accept (unused ):
4919
4922
server_accept_called .set ()
4920
- if not ready_for_server_wrap_socket .wait (support . SHORT_TIMEOUT ):
4923
+ if not ready_for_server_wrap_socket .wait (SHORT_TIMEOUT ):
4921
4924
raise RuntimeError ("wrap_socket event never set, test may fail." )
4922
4925
return False # Tell the server thread to continue.
4923
4926
@@ -4961,7 +4964,7 @@ def test_preauth_data_to_tls_client(self):
4961
4964
client_can_continue_with_wrap_socket = threading .Event ()
4962
4965
4963
4966
def call_after_accept (conn_to_client ):
4964
- if not server_can_continue_with_wrap_socket .wait (support . SHORT_TIMEOUT ):
4967
+ if not server_can_continue_with_wrap_socket .wait (SHORT_TIMEOUT ):
4965
4968
print ("ERROR: test client took too long" )
4966
4969
4967
4970
# This forces an immediate connection close via RST on .close().
@@ -4987,7 +4990,7 @@ def call_after_accept(conn_to_client):
4987
4990
client .connect (server .listener .getsockname ())
4988
4991
server_can_continue_with_wrap_socket .set ()
4989
4992
4990
- if not client_can_continue_with_wrap_socket .wait (support . SHORT_TIMEOUT ):
4993
+ if not client_can_continue_with_wrap_socket .wait (SHORT_TIMEOUT ):
4991
4994
self .fail ("test server took too long" )
4992
4995
ssl_ctx = ssl .create_default_context ()
4993
4996
try :
@@ -5026,7 +5029,7 @@ def connect(self):
5026
5029
http .client .HTTPConnection .connect (self )
5027
5030
5028
5031
# Wait for our fault injection server to have done its thing.
5029
- if not server_responding .wait (support . SHORT_TIMEOUT ) and support .verbose :
5032
+ if not server_responding .wait (SHORT_TIMEOUT ) and support .verbose :
5030
5033
sys .stdout .write ("server_responding event never set." )
5031
5034
self .sock = self ._context .wrap_socket (
5032
5035
self .sock , server_hostname = self .host )
@@ -5104,7 +5107,7 @@ def test_main(verbose=False):
5104
5107
tests = [
5105
5108
ContextTests , BasicSocketTests , SSLErrorTests , MemoryBIOTests ,
5106
5109
SSLObjectTests , SimpleBackgroundTests , ThreadedTests ,
5107
- TestPostHandshakeAuth , TestSSLDebug
5110
+ TestPostHandshakeAuth , TestSSLDebug , TestPreHandshakeClose
5108
5111
]
5109
5112
5110
5113
if support .is_resource_enabled ('network' ):
0 commit comments