From f2e8dbcc0067fb16b632de1984e622a8e99d9d8f Mon Sep 17 00:00:00 2001 From: pukkandan Date: Fri, 8 Jul 2022 16:53:05 +0530 Subject: [extractor, test] Basic framework for embed tests (#4307) and split download tests so they can be more easily run in CI Authored by: coletdjnz --- test/helper.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test/helper.py') diff --git a/test/helper.py b/test/helper.py index f19e1a34f..e918d8c46 100644 --- a/test/helper.py +++ b/test/helper.py @@ -92,6 +92,13 @@ def gettestcases(include_onlymatching=False): yield from ie.get_testcases(include_onlymatching) +def getwebpagetestcases(): + for ie in yt_dlp.extractor.gen_extractors(): + for tc in ie.get_webpage_testcases(): + tc.setdefault('add_ie', []).append('Generic') + yield tc + + md5 = lambda s: hashlib.md5(s.encode()).hexdigest() -- cgit v1.2.3 From 46d09f87072e112c363f4a573966d8e48a788562 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Mon, 7 Nov 2022 02:29:58 +0530 Subject: [cleanup] Lint and misc cleanup --- test/helper.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/helper.py') diff --git a/test/helper.py b/test/helper.py index e918d8c46..3b3b44580 100644 --- a/test/helper.py +++ b/test/helper.py @@ -260,8 +260,8 @@ def expect_info_dict(self, got_dict, expected_dict): info_dict_str += ''.join( f' {_repr(k)}: {_repr(test_info_dict[k])},\n' for k in missing_keys) - write_string( - '\n\'info_dict\': {\n' + info_dict_str + '},\n', out=sys.stderr) + info_dict_str = '\n\'info_dict\': {\n' + info_dict_str + '},\n' + write_string(info_dict_str.replace('\n', '\n '), out=sys.stderr) self.assertFalse( missing_keys, 'Missing keys in test definition: %s' % ( -- cgit v1.2.3 From 495322b95bbf8befa0f0b354f110a1d4eddac784 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Thu, 10 Nov 2022 07:32:25 +0530 Subject: [test] Allow `extract_flat` in download tests Authored by: coletdjnz, pukkandan --- test/helper.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'test/helper.py') diff --git a/test/helper.py b/test/helper.py index 3b3b44580..139bdafc3 100644 --- a/test/helper.py +++ b/test/helper.py @@ -222,6 +222,10 @@ def sanitize_got_info_dict(got_dict): if test_info_dict.get('display_id') == test_info_dict.get('id'): test_info_dict.pop('display_id') + # Check url for flat entries + if got_dict.get('_type', 'video') != 'video' and got_dict.get('url'): + test_info_dict['url'] = got_dict['url'] + return test_info_dict @@ -235,8 +239,9 @@ def expect_info_dict(self, got_dict, expected_dict): for key in mandatory_fields: self.assertTrue(got_dict.get(key), 'Missing mandatory field %s' % key) # Check for mandatory fields that are automatically set by YoutubeDL - for key in ['webpage_url', 'extractor', 'extractor_key']: - self.assertTrue(got_dict.get(key), 'Missing field: %s' % key) + if got_dict.get('_type', 'video') == 'video': + for key in ['webpage_url', 'extractor', 'extractor_key']: + self.assertTrue(got_dict.get(key), 'Missing field: %s' % key) test_info_dict = sanitize_got_info_dict(got_dict) -- cgit v1.2.3 From 7aaf4cd2a8fd8ecf2123b981782c3d12dce80d78 Mon Sep 17 00:00:00 2001 From: Robert Geislinger Date: Fri, 11 Nov 2022 08:43:08 +0530 Subject: [cleanup] Misc Closes #5471, Closes #5312 Authored by: pukkandan, Alienmaster --- test/helper.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'test/helper.py') diff --git a/test/helper.py b/test/helper.py index 139bdafc3..0b90660ff 100644 --- a/test/helper.py +++ b/test/helper.py @@ -254,14 +254,11 @@ def expect_info_dict(self, got_dict, expected_dict): return v.__name__ else: return repr(v) - info_dict_str = '' - if len(missing_keys) != len(expected_dict): - info_dict_str += ''.join( - f' {_repr(k)}: {_repr(v)},\n' - for k, v in test_info_dict.items() if k not in missing_keys) - - if info_dict_str: - info_dict_str += '\n' + info_dict_str = ''.join( + f' {_repr(k)}: {_repr(v)},\n' + for k, v in test_info_dict.items() if k not in missing_keys) + if info_dict_str: + info_dict_str += '\n' info_dict_str += ''.join( f' {_repr(k)}: {_repr(test_info_dict[k])},\n' for k in missing_keys) -- cgit v1.2.3