From b2ad967e4561f0bcb73fca3281341751471cab91 Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Mon, 7 Oct 2013 19:06:36 +0200 Subject: [PATCH] Simplify test setup --- test/helper.py | 7 +------ test/test_download.py | 9 +-------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/test/helper.py b/test/helper.py index 884cf32dc..ad1b74dd3 100644 --- a/test/helper.py +++ b/test/helper.py @@ -12,12 +12,7 @@ from youtube_dl.utils import ( compat_urllib_request, ) -# General configuration (from __init__, not very elegant...) -jar = compat_cookiejar.CookieJar() -cookie_processor = compat_urllib_request.HTTPCookieProcessor(jar) -proxy_handler = compat_urllib_request.ProxyHandler() -opener = compat_urllib_request.build_opener(proxy_handler, cookie_processor, YoutubeDLHandler()) -compat_urllib_request.install_opener(opener) +youtube_dl._setup_opener(timeout=10) PARAMETERS_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "parameters.json") with io.open(PARAMETERS_FILE, encoding='utf-8') as pf: diff --git a/test/test_download.py b/test/test_download.py index 23d3853c4..fdf59bb5c 100644 --- a/test/test_download.py +++ b/test/test_download.py @@ -19,14 +19,6 @@ PARAMETERS_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "para RETRIES = 3 -# General configuration (from __init__, not very elegant...) -jar = compat_cookiejar.CookieJar() -cookie_processor = compat_urllib_request.HTTPCookieProcessor(jar) -proxy_handler = compat_urllib_request.ProxyHandler() -opener = compat_urllib_request.build_opener(proxy_handler, cookie_processor, YoutubeDLHandler()) -compat_urllib_request.install_opener(opener) -socket.setdefaulttimeout(10) - md5 = lambda s: hashlib.md5(s.encode('utf-8')).hexdigest() class YoutubeDL(youtube_dl.YoutubeDL): @@ -45,6 +37,7 @@ def _file_md5(fn): with open(fn, 'rb') as f: return hashlib.md5(f.read()).hexdigest() +import helper # Set up remaining global configuration from helper import get_testcases, try_rm defs = get_testcases()