diff --git a/.gitignore b/.gitignore index 8fcd0de641..40bb34d2aa 100644 --- a/.gitignore +++ b/.gitignore @@ -105,6 +105,8 @@ README.txt *.zsh *.spec test/testdata/sigs/player-*.js +test/testdata/thumbnails/empty.webp +test/testdata/thumbnails/foo\ %d\ bar/foo_%d.* # Binary /youtube-dl diff --git a/Makefile b/Makefile index 6c72ead1ef..273cb3cc0b 100644 --- a/Makefile +++ b/Makefile @@ -18,10 +18,11 @@ pypi-files: AUTHORS Changelog.md LICENSE README.md README.txt supportedsites \ tar pypi-files lazy-extractors install uninstall clean-test: - rm -rf test/testdata/sigs/player-*.js tmp/ *.annotations.xml *.aria2 *.description *.dump *.frag \ + rm -rf tmp/ *.annotations.xml *.aria2 *.description *.dump *.frag \ *.frag.aria2 *.frag.urls *.info.json *.live_chat.json *.meta *.part* *.tmp *.temp *.unknown_video *.ytdl \ *.3gp *.ape *.ass *.avi *.desktop *.f4v *.flac *.flv *.gif *.jpeg *.jpg *.lrc *.m4a *.m4v *.mhtml *.mkv *.mov *.mp3 *.mp4 \ - *.mpg *.mpga *.oga *.ogg *.opus *.png *.sbv *.srt *.ssa *.swf *.tt *.ttml *.url *.vtt *.wav *.webloc *.webm *.webp + *.mpg *.mpga *.oga *.ogg *.opus *.png *.sbv *.srt *.ssa *.swf *.tt *.ttml *.url *.vtt *.wav *.webloc *.webm *.webp \ + test/testdata/sigs/player-*.js test/testdata/thumbnails/empty.webp "test/testdata/thumbnails/foo %d bar/foo_%d."* clean-dist: rm -rf yt-dlp.1.temp.md yt-dlp.1 README.txt MANIFEST build/ dist/ .coverage cover/ yt-dlp.tar.gz completions/ \ yt_dlp/extractor/lazy_extractors.py *.spec CONTRIBUTING.md.tmp yt-dlp yt-dlp.exe yt_dlp.egg-info/ AUTHORS diff --git a/test/test_postprocessors.py b/test/test_postprocessors.py index 603f85c654..ecc73e39eb 100644 --- a/test/test_postprocessors.py +++ b/test/test_postprocessors.py @@ -8,6 +8,8 @@ import unittest sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +import subprocess + from yt_dlp import YoutubeDL from yt_dlp.utils import shell_quote from yt_dlp.postprocessor import ( @@ -47,7 +49,18 @@ class TestConvertThumbnail(unittest.TestCase): print('Skipping: ffmpeg not found') return - file = 'test/testdata/thumbnails/foo %d bar/foo_%d.{}' + test_data_dir = 'test/testdata/thumbnails' + generated_file = f'{test_data_dir}/empty.webp' + + subprocess.check_call([ + pp.executable, '-y', '-f', 'lavfi', '-i', 'color=c=black:s=320x320', + '-c:v', 'libwebp', '-pix_fmt', 'yuv420p', '-vframes', '1', generated_file, + ], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + + file = test_data_dir + '/foo %d bar/foo_%d.{}' + initial_file = file.format('webp') + os.replace(generated_file, initial_file) + tests = (('webp', 'png'), ('png', 'jpg')) for inp, out in tests: @@ -55,11 +68,13 @@ class TestConvertThumbnail(unittest.TestCase): if os.path.exists(out_file): os.remove(out_file) pp.convert_thumbnail(file.format(inp), out) - assert os.path.exists(out_file) + self.assertTrue(os.path.exists(out_file)) for _, out in tests: os.remove(file.format(out)) + os.remove(initial_file) + class TestExec(unittest.TestCase): def test_parse_cmd(self): @@ -610,3 +625,7 @@ outpoint 10.000000 self.assertEqual( r"'special '\'' characters '\'' galore'\'\'\'", self._pp._quote_for_ffmpeg("special ' characters ' galore'''")) + + +if __name__ == '__main__': + unittest.main() diff --git a/test/testdata/thumbnails/foo %d bar/foo_%d.webp b/test/testdata/thumbnails/foo %d bar/foo_%d.webp deleted file mode 100644 index d64d0839f0..0000000000 Binary files a/test/testdata/thumbnails/foo %d bar/foo_%d.webp and /dev/null differ diff --git a/test/testdata/thumbnails/foo %d bar/placeholder b/test/testdata/thumbnails/foo %d bar/placeholder new file mode 100644 index 0000000000..e69de29bb2