[tests:results] enable 'extension' and ':?' in format tests

This commit is contained in:
Mike Fährmann
2025-05-26 13:48:46 +02:00
parent e4d139c3ce
commit 456e93d489
2 changed files with 21 additions and 17 deletions

View File

@@ -150,9 +150,9 @@ __tests__ = (
"#category": ("", "facebook", "video"),
"#class" : facebook.FacebookVideoExtractor,
"#count" : 2,
"#archive": False,
"filename" : "1514198129001376",
"filename" : str,
"extension": {"mp4", "m4a"},
"id" : "644342003942740",
"url" : str,
"user_id" : "100064860875397",

View File

@@ -402,27 +402,31 @@ class TestPathfmt():
class TestFormatter(formatter.StringFormatter):
@staticmethod
def _noop(_):
return ""
def _apply_simple(self, key, fmt):
if key == "extension" or "_parse_optional." in repr(fmt):
return self._noop
def wrap(obj):
return fmt(obj[key])
def wrap(obj):
try:
return fmt(obj[key])
except KeyError:
return ""
else:
def wrap(obj):
return fmt(obj[key])
return wrap
def _apply(self, key, funcs, fmt):
if key == "extension" or "_parse_optional." in repr(fmt):
return self._noop
def wrap(obj):
obj = obj[key]
for func in funcs:
obj = func(obj)
return fmt(obj)
def wrap(obj):
obj = obj[key] if key in obj else ""
for func in funcs:
obj = func(obj)
return fmt(obj)
else:
def wrap(obj):
obj = obj[key]
for func in funcs:
obj = func(obj)
return fmt(obj)
return wrap