projects
/
youtube-dl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Disable Stanford OC test for now, and enable escapist
[youtube-dl]
/
test
/
test_download.py
diff --git
a/test/test_download.py
b/test/test_download.py
index 4a59f6638997df30864337f8473e9138463dbb80..f1bccf58c5a2eaab0fbb8d60bb1185007eae0ee8 100644
(file)
--- a/
test/test_download.py
+++ b/
test/test_download.py
@@
-26,6
+26,7
@@
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)
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)
def _try_rm(filename):
""" Remove a file if it exists """
def _try_rm(filename):
""" Remove a file if it exists """
@@
-81,17
+82,24
@@
def generator(test_case):
fd.add_info_extractor(ie())
for ien in test_case.get('add_ie', []):
fd.add_info_extractor(getattr(youtube_dl.InfoExtractors, ien + 'IE')())
fd.add_info_extractor(ie())
for ien in test_case.get('add_ie', []):
fd.add_info_extractor(getattr(youtube_dl.InfoExtractors, ien + 'IE')())
+ finished_hook_called = set()
+ def _hook(status):
+ if status['status'] == 'finished':
+ finished_hook_called.add(status['filename'])
+ fd.add_progress_hook(_hook)
test_cases = test_case.get('playlist', [test_case])
for tc in test_cases:
_try_rm(tc['file'])
test_cases = test_case.get('playlist', [test_case])
for tc in test_cases:
_try_rm(tc['file'])
+ _try_rm(tc['file'] + '.part')
_try_rm(tc['file'] + '.info.json')
try:
fd.download([test_case['url']])
for tc in test_cases:
if not test_case.get('params', {}).get('skip_download', False):
_try_rm(tc['file'] + '.info.json')
try:
fd.download([test_case['url']])
for tc in test_cases:
if not test_case.get('params', {}).get('skip_download', False):
- self.assertTrue(os.path.exists(tc['file']))
+ self.assertTrue(os.path.exists(tc['file']), msg='Missing file ' + tc['file'])
+ self.assertTrue(tc['file'] in finished_hook_called)
self.assertTrue(os.path.exists(tc['file'] + '.info.json'))
if 'md5' in tc:
md5_for_file = _file_md5(tc['file'])
self.assertTrue(os.path.exists(tc['file'] + '.info.json'))
if 'md5' in tc:
md5_for_file = _file_md5(tc['file'])
@@
-99,14
+107,11
@@
def generator(test_case):
with io.open(tc['file'] + '.info.json', encoding='utf-8') as infof:
info_dict = json.load(infof)
for (info_field, value) in tc.get('info_dict', {}).items():
with io.open(tc['file'] + '.info.json', encoding='utf-8') as infof:
info_dict = json.load(infof)
for (info_field, value) in tc.get('info_dict', {}).items():
- if value.startswith('md5:'):
- md5_info_value = hashlib.md5(info_dict.get(info_field, '')).hexdigest()
- self.assertEqual(value[3:], md5_info_value)
- else:
- self.assertEqual(value, info_dict.get(info_field))
+ self.assertEqual(value, info_dict.get(info_field))
finally:
for tc in test_cases:
_try_rm(tc['file'])
finally:
for tc in test_cases:
_try_rm(tc['file'])
+ _try_rm(tc['file'] + '.part')
_try_rm(tc['file'] + '.info.json')
return test_template
_try_rm(tc['file'] + '.info.json')
return test_template