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