From 7aba64519c7f2c3150b1ff05cce3c07b5d551506 Mon Sep 17 00:00:00 2001 From: InvalidUsernameException Date: Mon, 9 Jun 2025 19:42:15 +0200 Subject: [PATCH] Add support for `playlist_maxcount` assertion in download tests --- test/test_download.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/test/test_download.py b/test/test_download.py index 3f36869d9..98087fcd3 100755 --- a/test/test_download.py +++ b/test/test_download.py @@ -14,6 +14,7 @@ from test.helper import ( assertGreaterEqual, + assertLessEqual, expect_info_dict, expect_warnings, get_params, @@ -122,8 +123,10 @@ def print_skipping(reason): params['outtmpl'] = tname + '_' + params['outtmpl'] if is_playlist and 'playlist' not in test_case: params.setdefault('extract_flat', 'in_playlist') - params.setdefault('playlistend', test_case.get( - 'playlist_mincount', test_case.get('playlist_count', -2) + 1)) + params.setdefault('playlistend', max( + test_case.get('playlist_mincount') or -1, + (test_case.get('playlist_count') or -2) + 1, + (test_case.get('playlist_maxcount') or -2) + 1)) params.setdefault('skip_download', True) ydl = YoutubeDL(params, auto_init=False) @@ -211,6 +214,14 @@ def try_rm_tcs_files(tcs=None): test_case['url'], len(res_dict['entries']), )) + if 'playlist_maxcount' in test_case: + assertLessEqual( + self, + len(res_dict['entries']), + test_case['playlist_maxcount'], + 'Expected at most %d in playlist %s, but got %d' % ( + test_case['playlist_maxcount'], test_case['url'], + len(res_dict['entries']))) if 'playlist_duration_sum' in test_case: got_duration = sum(e['duration'] for e in res_dict['entries']) self.assertEqual(