]> jfr.im git - yt-dlp.git/blobdiff - test/helper.py
[youtube, cleanup] Minor refactoring
[yt-dlp.git] / test / helper.py
index 598f803f48513d881343c4034c5eb1f4695b2efa..28c21b2eb6794d483027564f7ad8ca199eba678c 100644 (file)
@@ -196,15 +196,7 @@ def expect_dict(self, got_dict, expected_dict):
 
 def sanitize_got_info_dict(got_dict):
     IGNORED_FIELDS = (
-        # Format keys
-        'url', 'manifest_url', 'format', 'format_id', 'format_note', 'width', 'height', 'resolution',
-        'dynamic_range', 'tbr', 'abr', 'acodec', 'asr', 'vbr', 'fps', 'vcodec', 'container', 'filesize',
-        'filesize_approx', 'player_url', 'protocol', 'fragment_base_url', 'fragments', 'preference',
-        'language', 'language_preference', 'quality', 'source_preference', 'http_headers',
-        'stretched_ratio', 'no_resume', 'has_drm', 'downloader_options',
-
-        # RTMP formats
-        'page_url', 'app', 'play_path', 'tc_url', 'flash_version', 'rtmp_live', 'rtmp_conn', 'rtmp_protocol', 'rtmp_real_time',
+        *YoutubeDL._format_fields,
 
         # Lists
         'formats', 'thumbnails', 'subtitles', 'automatic_captions', 'comments', 'entries',
@@ -220,10 +212,12 @@ def sanitize_got_info_dict(got_dict):
     IGNORED_PREFIXES = ('', 'playlist', 'requested', 'webpage')
 
     def sanitize(key, value):
-        if isinstance(value, str) and len(value) > 100:
+        if isinstance(value, str) and len(value) > 100 and key != 'thumbnail':
             return f'md5:{md5(value)}'
         elif isinstance(value, list) and len(value) > 10:
             return f'count:{len(value)}'
+        elif key.endswith('_count') and isinstance(value, int):
+            return int
         return value
 
     test_info_dict = {
@@ -233,7 +227,7 @@ def sanitize(key, value):
     }
 
     # display_id may be generated from id
-    if test_info_dict.get('display_id') == test_info_dict['id']:
+    if test_info_dict.get('display_id') == test_info_dict.get('id'):
         test_info_dict.pop('display_id')
 
     return test_info_dict
@@ -259,6 +253,8 @@ def expect_info_dict(self, got_dict, expected_dict):
         def _repr(v):
             if isinstance(v, compat_str):
                 return "'%s'" % v.replace('\\', '\\\\').replace("'", "\\'").replace('\n', '\\n')
+            elif isinstance(v, type):
+                return v.__name__
             else:
                 return repr(v)
         info_dict_str = ''