mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-12-24 17:08:53 +00:00
Fixed up tests and linting
This commit is contained in:
@@ -874,32 +874,33 @@ class TestYoutubeDL(unittest.TestCase):
|
||||
}), r'^30fps$')
|
||||
|
||||
def test_postprocessors(self):
|
||||
filename = 'post-processor-testfile.mp4'
|
||||
audiofile = filename + '.mp3'
|
||||
filename = 'post-processor-testfile'
|
||||
video_file = filename + '.mp4'
|
||||
audio_file = filename + '.mp3'
|
||||
|
||||
class SimplePP(PostProcessor):
|
||||
def run(self, info):
|
||||
with open(audiofile, 'w') as f:
|
||||
with open(audio_file, 'w') as f:
|
||||
f.write('EXAMPLE')
|
||||
return [info['filepath']], info
|
||||
|
||||
def run_pp(params, PP):
|
||||
with open(filename, 'w') as f:
|
||||
with open(video_file, 'w') as f:
|
||||
f.write('EXAMPLE')
|
||||
ydl = YoutubeDL(params)
|
||||
ydl.add_post_processor(PP())
|
||||
ydl.post_process(filename, {'filepath': filename})
|
||||
ydl.post_process(video_file, {'filepath': video_file})
|
||||
|
||||
run_pp({'keepvideo': True}, SimplePP)
|
||||
self.assertTrue(os.path.exists(filename), '%s doesn\'t exist' % filename)
|
||||
self.assertTrue(os.path.exists(audiofile), '%s doesn\'t exist' % audiofile)
|
||||
os.unlink(filename)
|
||||
os.unlink(audiofile)
|
||||
run_pp({'keepvideo': True, 'outtmpl': filename}, SimplePP)
|
||||
self.assertTrue(os.path.exists(video_file), '%s doesn\'t exist' % video_file)
|
||||
self.assertTrue(os.path.exists(audio_file), '%s doesn\'t exist' % audio_file)
|
||||
os.unlink(video_file)
|
||||
os.unlink(audio_file)
|
||||
|
||||
run_pp({'keepvideo': False}, SimplePP)
|
||||
self.assertFalse(os.path.exists(filename), '%s exists' % filename)
|
||||
self.assertTrue(os.path.exists(audiofile), '%s doesn\'t exist' % audiofile)
|
||||
os.unlink(audiofile)
|
||||
run_pp({'keepvideo': False, 'outtmpl': filename}, SimplePP)
|
||||
self.assertFalse(os.path.exists(video_file), '%s exists' % video_file)
|
||||
self.assertTrue(os.path.exists(audio_file), '%s doesn\'t exist' % audio_file)
|
||||
os.unlink(audio_file)
|
||||
|
||||
class ModifierPP(PostProcessor):
|
||||
def run(self, info):
|
||||
@@ -907,9 +908,9 @@ class TestYoutubeDL(unittest.TestCase):
|
||||
f.write('MODIFIED')
|
||||
return [], info
|
||||
|
||||
run_pp({'keepvideo': False}, ModifierPP)
|
||||
self.assertTrue(os.path.exists(filename), '%s doesn\'t exist' % filename)
|
||||
os.unlink(filename)
|
||||
run_pp({'keepvideo': False, 'outtmpl': filename}, ModifierPP)
|
||||
self.assertTrue(os.path.exists(video_file), '%s doesn\'t exist' % video_file)
|
||||
os.unlink(video_file)
|
||||
|
||||
def test_match_filter(self):
|
||||
first = {
|
||||
|
||||
Reference in New Issue
Block a user