]>
jfr.im git - yt-dlp.git/blob - test/test_overwrites.py
7 sys
.path
.insert(0, os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
))))
9 from test
.helper
import is_download_test
, try_rm
11 root_dir
= os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
)))
12 download_file
= os
.path
.join(root_dir
, 'test.webm')
16 class TestOverwrites(unittest
.TestCase
):
18 # create an empty file
19 open(download_file
, 'a').close()
21 def test_default_overwrites(self
):
22 outp
= subprocess
.Popen(
24 sys
.executable
, 'yt_dlp/__main__.py',
26 'https://www.youtube.com/watch?v=jNQXAC9IVRw'
27 ], cwd
=root_dir
, stdout
=subprocess
.PIPE
, stderr
=subprocess
.PIPE
)
28 sout
, serr
= outp
.communicate()
29 self
.assertTrue(b
'has already been downloaded' in sout
)
30 # if the file has no content, it has not been redownloaded
31 self
.assertTrue(os
.path
.getsize(download_file
) < 1)
33 def test_yes_overwrites(self
):
34 outp
= subprocess
.Popen(
36 sys
.executable
, 'yt_dlp/__main__.py', '--yes-overwrites',
38 'https://www.youtube.com/watch?v=jNQXAC9IVRw'
39 ], cwd
=root_dir
, stdout
=subprocess
.PIPE
, stderr
=subprocess
.PIPE
)
40 sout
, serr
= outp
.communicate()
41 self
.assertTrue(b
'has already been downloaded' not in sout
)
42 # if the file has no content, it has not been redownloaded
43 self
.assertTrue(os
.path
.getsize(download_file
) > 1)
46 try_rm(os
.path
.join(root_dir
, 'test.webm'))
49 if __name__
== '__main__':