diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-08-07 21:16:55 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2021-08-07 21:16:55 +0530 |
commit | 6e84b21559f586ee4d6affb61688d5c6a0c21221 (patch) | |
tree | 2af80b63dafd747cebbed3b3c3b1e3ad0238ab1e /test/test_YoutubeDL.py | |
parent | 575e17a1b912ace50ac383e74a8da5b8e9c8de4e (diff) | |
download | hypervideo-pre-6e84b21559f586ee4d6affb61688d5c6a0c21221.tar.lz hypervideo-pre-6e84b21559f586ee4d6affb61688d5c6a0c21221.tar.xz hypervideo-pre-6e84b21559f586ee4d6affb61688d5c6a0c21221.zip |
Fix bugs related to `sanitize_info`
Related: https://github.com/yt-dlp/yt-dlp/commit/8012d892bd38af731357a61e071e0a0d01bc41b4#r54555230
Diffstat (limited to 'test/test_YoutubeDL.py')
-rw-r--r-- | test/test_YoutubeDL.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/test/test_YoutubeDL.py b/test/test_YoutubeDL.py index 9a0b286e2..1e0865102 100644 --- a/test/test_YoutubeDL.py +++ b/test/test_YoutubeDL.py @@ -18,7 +18,7 @@ from yt_dlp.compat import compat_os_name, compat_setenv, compat_str, compat_urll from yt_dlp.extractor import YoutubeIE from yt_dlp.extractor.common import InfoExtractor from yt_dlp.postprocessor.common import PostProcessor -from yt_dlp.utils import ExtractorError, int_or_none, match_filter_func +from yt_dlp.utils import ExtractorError, int_or_none, match_filter_func, LazyList TEST_URL = 'http://localhost/sample.mp4' @@ -678,10 +678,17 @@ class TestYoutubeDL(unittest.TestCase): self.assertEqual(out, expected[0]) self.assertEqual(fname, expected[1]) + # Side-effects + original_infodict = dict(self.outtmpl_info) + test('foo.bar', 'foo.bar') + original_infodict['epoch'] = self.outtmpl_info.get('epoch') + self.assertTrue(isinstance(original_infodict['epoch'], int)) + test('%(epoch)d', int_or_none) + self.assertEqual(original_infodict, self.outtmpl_info) + # Auto-generated fields test('%(id)s.%(ext)s', '1234.mp4') test('%(duration_string)s', ('27:46:40', '27-46-40')) - test('%(epoch)d', int_or_none) test('%(resolution)s', '1080p') test('%(playlist_index)s', '001') test('%(autonumber)s', '00001') @@ -774,6 +781,12 @@ class TestYoutubeDL(unittest.TestCase): test('%(formats.0.id.-1+id)f', '1235.000000') test('%(formats.0.id.-1+formats.1.id.-1)d', '3') + # Laziness + def gen(): + yield from range(5) + raise self.assertTrue(False, 'LazyList should not be evaluated till here') + test('%(key.4)s', '4', info={'key': LazyList(gen())}) + # Empty filename test('%(foo|)s-%(bar|)s.%(ext)s', '-.mp4') # test('%(foo|)s.%(ext)s', ('.mp4', '_.mp4')) # fixme |