diff --git a/test/test_download.py b/test/test_download.py index ebe820dfc..329f569c2 100644 --- a/test/test_download.py +++ b/test/test_download.py @@ -37,6 +37,7 @@ from youtube_dl.utils import ( UnavailableVideoError, ) from youtube_dl.extractor import get_info_extractor +from youtube_dl.downloader.common import FileDownloader RETRIES = 3 @@ -56,9 +57,10 @@ class YoutubeDL(youtube_dl.YoutubeDL): return super(YoutubeDL, self).process_info(info_dict) -def _file_md5(fn): +def _file_md5(fn, length=None): with open(fn, 'rb') as f: - return hashlib.md5(f.read()).hexdigest() + return hashlib.md5( + f.read(length) if length is not None else f.read()).hexdigest() defs = gettestcases() @@ -224,7 +226,7 @@ def generator(test_case, tname): (tc_filename, format_bytes(expected_minsize), format_bytes(got_fsize))) if 'md5' in tc: - md5_for_file = _file_md5(tc_filename) + md5_for_file = _file_md5(tc_filename) if not params.get('test') else _file_md5(tc_filename, FileDownloader._TEST_FILE_SIZE) self.assertEqual(tc['md5'], md5_for_file) # Finally, check test cases' data again but this time against # extracted data from info JSON file written during processing