diff options
author | Philipp Hagemeister <phihag@phihag.de> | 2014-08-28 13:59:42 +0200 |
---|---|---|
committer | Philipp Hagemeister <phihag@phihag.de> | 2014-08-28 13:59:45 +0200 |
commit | 753727cdedfbafa90884f88fa44d45b3ebdc9cfa (patch) | |
tree | 0b470977b57748a43748ac3807ea654e0190d8f9 /test/test_download.py | |
parent | daebaab692be24805451b90f848ec5d5e7d3bb8d (diff) |
[test_download] Expect a minimum file size
This should detect when we're downloading a small text file by accident.
Diffstat (limited to 'test/test_download.py')
-rw-r--r-- | test/test_download.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/test_download.py b/test/test_download.py index 770fff588..9845ba8c6 100644 --- a/test/test_download.py +++ b/test/test_download.py @@ -28,6 +28,7 @@ from youtube_dl.utils import ( compat_HTTPError, DownloadError, ExtractorError, + format_bytes, UnavailableVideoError, ) from youtube_dl.extractor import get_info_extractor @@ -171,6 +172,16 @@ def generator(test_case): if 'md5' in tc: md5_for_file = _file_md5(tc_filename) 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: info_dict = json.load(infof) |