]> jfr.im git - yt-dlp.git/commitdiff
[test:download] Support testing with `ignore_no_formats_error`
authorpukkandan <redacted>
Sun, 1 Aug 2021 22:16:45 +0000 (03:46 +0530)
committerpukkandan <redacted>
Sun, 1 Aug 2021 22:17:31 +0000 (03:47 +0530)
test/helper.py
test/test_download.py

index b40ffe3cef777fe119974536f2ab51e9f8e9adb1..9599eab8e2ebc5948e0f194ebd62175fc9b9b817 100644 (file)
@@ -198,7 +198,10 @@ def expect_info_dict(self, got_dict, expected_dict):
     expect_dict(self, got_dict, expected_dict)
     # Check for the presence of mandatory fields
     if got_dict.get('_type') not in ('playlist', 'multi_video'):
-        for key in ('id', 'url', 'title', 'ext'):
+        mandatory_fields = ['id', 'title']
+        if expected_dict.get('ext'):
+            mandatory_fields.extend(('url', 'ext'))
+        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']:
index e4485ce81855707464b2e489ede68e14c2bc0c9c..54674845480eace58b15763f7409f72f5155b6c0 100644 (file)
@@ -108,8 +108,13 @@ def print_skipping(reason):
 
         for tc in test_cases:
             info_dict = tc.get('info_dict', {})
-            if not (info_dict.get('id') and info_dict.get('ext')):
-                raise Exception('Test definition incorrect. The output file cannot be known. Are both \'id\' and \'ext\' keys present?')
+            params = tc.get('params', {})
+            if not info_dict.get('id'):
+                raise Exception('Test definition incorrect. \'id\' key is not present')
+            elif not info_dict.get('ext'):
+                if params.get('skip_download') and params.get('ignore_no_formats_error'):
+                    continue
+                raise Exception('Test definition incorrect. The output file cannot be known. \'ext\' key is not present')
 
         if 'skip' in test_case:
             print_skipping(test_case['skip'])