From: Christian Heimes Date: Sat, 24 Apr 2021 05:54:08 +0000 (+0200) Subject: bpo-31870: Fix test_get_server_certificate_timeout on Windows (GH-25570) X-Git-Tag: v3.10.0b1~180 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f05c2aed7e25087122613b51f152919c79641f66;p=thirdparty%2FPython%2Fcpython.git bpo-31870: Fix test_get_server_certificate_timeout on Windows (GH-25570) Some OS do not support millisecond granularity in select(). Use 100ms timeout and a server callback with sleep to emulate a slow server. --- diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py index 327a550645b4..31e1e7311daa 100644 --- a/Lib/test/test_ssl.py +++ b/Lib/test/test_ssl.py @@ -2137,9 +2137,13 @@ class SimpleBackgroundTests(unittest.TestCase): _test_get_server_certificate_fail(self, *self.server_addr) def test_get_server_certificate_timeout(self): + def servername_cb(ssl_sock, server_name, initial_context): + time.sleep(0.2) + self.server_context.set_servername_callback(servername_cb) + with self.assertRaises(socket.timeout): ssl.get_server_certificate(self.server_addr, ca_certs=SIGNING_CA, - timeout=0.0001) + timeout=0.1) def test_ciphers(self): with test_wrap_socket(socket.socket(socket.AF_INET),