1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-07-09 14:58:32 +00:00

Update tests

This commit is contained in:
7x11x13 2025-01-07 15:19:52 -05:00
parent 1e82fe3bfe
commit a6068e695c

View File

@ -697,6 +697,7 @@ def test_add_extra_info(self):
'title3': 'foo/bar\\test',
'title4': 'foo "bar" test',
'title5': 'áéí 𝐀',
'title6': '' * 10,
'timestamp': 1618488000,
'duration': 100000,
'playlist_index': 1,
@ -712,6 +713,8 @@ def test_add_extra_info(self):
def test_prepare_outtmpl_and_filename(self):
def test(tmpl, expected, *, info=None, **params):
if 'trim_file_name' not in params:
params['trim_file_name'] = 0 # disable trimming
params['outtmpl'] = tmpl
ydl = FakeYDL(params)
ydl._num_downloads = 1
@ -791,7 +794,7 @@ def expect_same_infodict(out):
self.assertEqual(got_dict.get(info_field), expected, info_field)
return True
test('%()j', (expect_same_infodict, None), trim_file_name=0)
test('%()j', (expect_same_infodict, None))
# NA placeholder
NA_TEST_OUTTMPL = '%(uploader_date)s-%(width)d-%(x|def)s-%(id)s.%(ext)s'
@ -924,6 +927,16 @@ def gen():
test('%(title3)s', ('foo/bar\\test', 'foobartest'))
test('folder/%(title3)s', ('folder/foo/bar\\test', f'folder{os.path.sep}foobartest'))
# --trim-filenames
test('%(title6)s.%(ext)s', '' * 10 + '.mp4')
test('%(title6)s.%(ext)s', '' * 3 + '.mp4', trim_file_name='3c')
test('%(title6)s.%(ext)s', '' * 3 + '.mp4', trim_file_name='9b', filesystem_encoding='utf-8')
test('%(title6)s.%(ext)s', '' * 3 + '.mp4', trim_file_name='10b', filesystem_encoding='utf-8')
test('%(title6)s.%(ext)s', '' * 3 + '.mp4', trim_file_name='11b', filesystem_encoding='utf-8')
test('%(title6)s.%(ext)s', '' * 4 + '.mp4', trim_file_name='12b', filesystem_encoding='utf-8')
test('%(title6)s.%(ext)s', '' * 6 + '.mp4', trim_file_name='12b', filesystem_encoding='utf-16le')
test('folder/%(title6)s.%(ext)s', f'folder{os.path.sep}あああ.mp4', trim_file_name='3c')
def test_format_note(self):
ydl = YoutubeDL()
self.assertEqual(ydl._format_note({}), '')