From 09ac3751ffa64fa9291558a045ad338373afe60f Mon Sep 17 00:00:00 2001 From: Illia Volochii Date: Wed, 19 Jul 2023 16:49:40 +0300 Subject: [PATCH] Try 7 --- test/with_dummyserver/test_socketlevel.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/with_dummyserver/test_socketlevel.py b/test/with_dummyserver/test_socketlevel.py index 51a801b3b6..bcb5ccb9e4 100644 --- a/test/with_dummyserver/test_socketlevel.py +++ b/test/with_dummyserver/test_socketlevel.py @@ -1620,7 +1620,13 @@ def test_requesting_large_resources_via_ssl( https://github.com/urllib3/urllib3/issues/2513 """ content_length = 2**31 # (`int` max value in C) + 1. - port = 52549 + + # A hack to find a free port. + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.bind(("0.0.0.0", 0)) + sock.listen() + port = sock.getsockname()[1] + sock.close() # OpenSSL server won't be allowed to open the file unless `delete=False`. temp_file = tempfile.NamedTemporaryFile(delete=False)