aboutsummaryrefslogtreecommitdiff
path: root/test/helper.py
diff options
context:
space:
mode:
authorXiao Di Guan <xdg@puxlit.net>2018-11-03 05:18:20 +1100
committerSergey M <dstftw@gmail.com>2018-11-03 01:18:20 +0700
commit95e42d7336d01f505d6551a21df52f3ae234e96b (patch)
tree795dc08fedf4db29ac64a938197bebf7f5f0ebfe /test/helper.py
parentcf0db4d99785532d767d0ca1cc029c73d16bb045 (diff)
downloadyoutube-dl-95e42d7336d01f505d6551a21df52f3ae234e96b.tar.xz
[extractor/common] Ensure response handle is not prematurely closed before it can be read if it matches expected_status (resolves #17195, closes #17846, resolves #17447)
Diffstat (limited to 'test/helper.py')
-rw-r--r--test/helper.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/helper.py b/test/helper.py
index dfee217a9..aa9a1c9b2 100644
--- a/test/helper.py
+++ b/test/helper.py
@@ -7,6 +7,7 @@ import json
import os.path
import re
import types
+import ssl
import sys
import youtube_dl.extractor
@@ -244,3 +245,12 @@ def expect_warnings(ydl, warnings_re):
real_warning(w)
ydl.report_warning = _report_warning
+
+
+def http_server_port(httpd):
+ if os.name == 'java' and isinstance(httpd.socket, ssl.SSLSocket):
+ # In Jython SSLSocket is not a subclass of socket.socket
+ sock = httpd.socket.sock
+ else:
+ sock = httpd.socket
+ return sock.getsockname()[1]