[tests:results] enable 'extension' and ':?' in format tests
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user