Skip to content

Commit

Permalink
[test, etc] Improve download test logs; also clean up some new flake8…
Browse files Browse the repository at this point in the history
… issues (#31153)

* [test] Identify testcase errors better
* [test] Identify download errors better
* [extractor/minds] Linter
* [extractor/aes] Linter
  • Loading branch information
dirkf committed Aug 9, 2022
1 parent adb5294 commit deee741
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions test/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from youtube_dl.utils import (
DownloadError,
ExtractorError,
error_to_compat_str,
format_bytes,
UnavailableVideoError,
)
Expand Down Expand Up @@ -108,7 +109,7 @@ def print_skipping(reason):
for tc in test_cases:
info_dict = tc.get('info_dict', {})
if not (info_dict.get('id') and info_dict.get('ext')):
raise Exception('Test definition incorrect. The output file cannot be known. Are both \'id\' and \'ext\' keys present?')
raise Exception('Test definition (%s) requires both \'id\' and \'ext\' keys present to define the output file' % (tname, ))

if 'skip' in test_case:
print_skipping(test_case['skip'])
Expand Down Expand Up @@ -161,7 +162,9 @@ def try_rm_tcs_files(tcs=None):
except (DownloadError, ExtractorError) as err:
# Check if the exception is not a network related one
if not err.exc_info[0] in (compat_urllib_error.URLError, socket.timeout, UnavailableVideoError, compat_http_client.BadStatusLine) or (err.exc_info[0] == compat_HTTPError and err.exc_info[1].code == 503):
raise
msg = getattr(err, 'msg', error_to_compat_str(err))
err.msg = '%s (%s)' % (msg, tname, )
raise err

if try_num == RETRIES:
report_warning('%s failed due to network errors, skipping...' % tname)
Expand Down
2 changes: 1 addition & 1 deletion youtube_dl/aes.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def xor(data1, data2):


def rijndael_mul(a, b):
if(a == 0 or b == 0):
if (a == 0 or b == 0):
return 0
return RIJNDAEL_EXP_TABLE[(RIJNDAEL_LOG_TABLE[a] + RIJNDAEL_LOG_TABLE[b]) % 0xFF]

Expand Down
2 changes: 1 addition & 1 deletion youtube_dl/extractor/minds.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _real_extract(self, url):
else:
return self.url_result(entity['perma_url'])
else:
assert(entity['subtype'] == 'video')
assert (entity['subtype'] == 'video')
video_id = entity_id
# 1080p and webm formats available only on the sources array
video = self._call_api(
Expand Down

0 comments on commit deee741

Please sign in to comment.