3 # Allow direct execution
8 sys
.path
.insert(0, os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
))))
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')
20 class TestOverwrites(unittest
.TestCase
):
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',
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',
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)
50 try_rm(os
.path
.join(root_dir
, 'test.webm'))
53 if __name__
== '__main__':