mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-03 19:29:51 +01:00
[test_download] Expect a minimum file size
This should detect when we're downloading a small text file by accident.
This commit is contained in:
parent
daebaab692
commit
753727cded
@ -28,6 +28,7 @@
|
|||||||
compat_HTTPError,
|
compat_HTTPError,
|
||||||
DownloadError,
|
DownloadError,
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
|
format_bytes,
|
||||||
UnavailableVideoError,
|
UnavailableVideoError,
|
||||||
)
|
)
|
||||||
from youtube_dl.extractor import get_info_extractor
|
from youtube_dl.extractor import get_info_extractor
|
||||||
@ -171,6 +172,16 @@ def try_rm_tcs_files(tcs=None):
|
|||||||
if 'md5' in tc:
|
if 'md5' in tc:
|
||||||
md5_for_file = _file_md5(tc_filename)
|
md5_for_file = _file_md5(tc_filename)
|
||||||
self.assertEqual(md5_for_file, tc['md5'])
|
self.assertEqual(md5_for_file, tc['md5'])
|
||||||
|
expected_minsize = tc.get('file_minsize', 10000)
|
||||||
|
if expected_minsize is not None:
|
||||||
|
if params.get('test'):
|
||||||
|
expected_minsize = max(expected_minsize, 10000)
|
||||||
|
got_fsize = os.path.getsize(tc_filename)
|
||||||
|
assertGreaterEqual(
|
||||||
|
self, got_fsize, expected_minsize,
|
||||||
|
'Expected %s to be at least %s, but it\'s only %s ' %
|
||||||
|
(tc_filename, format_bytes(expected_minsize),
|
||||||
|
format_bytes(got_fsize)))
|
||||||
with io.open(info_json_fn, encoding='utf-8') as infof:
|
with io.open(info_json_fn, encoding='utf-8') as infof:
|
||||||
info_dict = json.load(infof)
|
info_dict = json.load(infof)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user