diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-07-07 21:05:58 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-07-07 21:10:43 +0530 |
commit | b5ac45b1971b39c2dc7296601516c68e7747e228 (patch) | |
tree | 45ebc6239da00f87e0d18debce1d119b19525d8e /test/test_YoutubeDL.py | |
parent | 38a40c9e160dc2e46e0acb3039dbdef1a18d2d36 (diff) | |
download | hypervideo-pre-b5ac45b1971b39c2dc7296601516c68e7747e228.tar.lz hypervideo-pre-b5ac45b1971b39c2dc7296601516c68e7747e228.tar.xz hypervideo-pre-b5ac45b1971b39c2dc7296601516c68e7747e228.zip |
Fix selectors `all`, `mergeall` and add tests
Bug from: 981052c9c6febb33b6547140a67a49ac0f5f4578
Diffstat (limited to 'test/test_YoutubeDL.py')
-rw-r--r-- | test/test_YoutubeDL.py | 50 |
1 files changed, 21 insertions, 29 deletions
diff --git a/test/test_YoutubeDL.py b/test/test_YoutubeDL.py index c02bfadfc..555a516e6 100644 --- a/test/test_YoutubeDL.py +++ b/test/test_YoutubeDL.py @@ -35,6 +35,9 @@ class YDL(FakeYDL): def to_screen(self, msg): self.msgs.append(msg) + def dl(self, *args, **kwargs): + assert False, 'Downloader must not be invoked for test_YoutubeDL' + def _make_result(formats, **kwargs): res = { @@ -117,35 +120,24 @@ class TestFormatSelection(unittest.TestCase): ] info_dict = _make_result(formats) - ydl = YDL({'format': '20/47'}) - ydl.process_ie_result(info_dict.copy()) - downloaded = ydl.downloaded_info_dicts[0] - self.assertEqual(downloaded['format_id'], '47') - - ydl = YDL({'format': '20/71/worst'}) - ydl.process_ie_result(info_dict.copy()) - downloaded = ydl.downloaded_info_dicts[0] - self.assertEqual(downloaded['format_id'], '35') - - ydl = YDL() - ydl.process_ie_result(info_dict.copy()) - downloaded = ydl.downloaded_info_dicts[0] - self.assertEqual(downloaded['format_id'], '2') - - ydl = YDL({'format': 'webm/mp4'}) - ydl.process_ie_result(info_dict.copy()) - downloaded = ydl.downloaded_info_dicts[0] - self.assertEqual(downloaded['format_id'], '47') - - ydl = YDL({'format': '3gp/40/mp4'}) - ydl.process_ie_result(info_dict.copy()) - downloaded = ydl.downloaded_info_dicts[0] - self.assertEqual(downloaded['format_id'], '35') - - ydl = YDL({'format': 'example-with-dashes'}) - ydl.process_ie_result(info_dict.copy()) - downloaded = ydl.downloaded_info_dicts[0] - self.assertEqual(downloaded['format_id'], 'example-with-dashes') + def test(inp, *expected, multi=False): + ydl = YDL({ + 'format': inp, + 'allow_multiple_video_streams': multi, + 'allow_multiple_audio_streams': multi, + }) + ydl.process_ie_result(info_dict.copy()) + downloaded = map(lambda x: x['format_id'], ydl.downloaded_info_dicts) + self.assertEqual(list(downloaded), list(expected)) + + test('20/47', '47') + test('20/71/worst', '35') + test(None, '2') + test('webm/mp4', '47') + test('3gp/40/mp4', '35') + test('example-with-dashes', 'example-with-dashes') + test('all', '35', 'example-with-dashes', '45', '47', '2') # Order doesn't actually matter for this + test('mergeall', '2+47+45+example-with-dashes+35', multi=True) def test_format_selection_audio(self): formats = [ |