[ie/bitchute] Fix extractors (#10301)
[yt-dlp3.git] / test / test_overwrites.py
blob0beafdf12e15e273198e21699e34cf1e40ac370d
1 #!/usr/bin/env python3
3 # Allow direct execution
4 import os
5 import sys
6 import unittest
8 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
11 import subprocess
13 from test.helper import is_download_test, try_rm
15 root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
16 download_file = os.path.join(root_dir, 'test.webm')
19 @is_download_test
20 class TestOverwrites(unittest.TestCase):
21 def setUp(self):
22 # create an empty file
23 open(download_file, 'a').close()
25 def test_default_overwrites(self):
26 outp = subprocess.Popen(
28 sys.executable, 'yt_dlp/__main__.py',
29 '-o', 'test.webm',
30 'https://www.youtube.com/watch?v=jNQXAC9IVRw',
31 ], cwd=root_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
32 sout, serr = outp.communicate()
33 self.assertTrue(b'has already been downloaded' in sout)
34 # if the file has no content, it has not been redownloaded
35 self.assertTrue(os.path.getsize(download_file) < 1)
37 def test_yes_overwrites(self):
38 outp = subprocess.Popen(
40 sys.executable, 'yt_dlp/__main__.py', '--yes-overwrites',
41 '-o', 'test.webm',
42 'https://www.youtube.com/watch?v=jNQXAC9IVRw',
43 ], cwd=root_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
44 sout, serr = outp.communicate()
45 self.assertTrue(b'has already been downloaded' not in sout)
46 # if the file has no content, it has not been redownloaded
47 self.assertTrue(os.path.getsize(download_file) > 1)
49 def tearDown(self):
50 try_rm(os.path.join(root_dir, 'test.webm'))
53 if __name__ == '__main__':
54 unittest.main()