[tests:results] enable 'extension' and ':?' in format tests
This commit is contained in:
@@ -150,9 +150,9 @@ __tests__ = (
|
|||||||
"#category": ("", "facebook", "video"),
|
"#category": ("", "facebook", "video"),
|
||||||
"#class" : facebook.FacebookVideoExtractor,
|
"#class" : facebook.FacebookVideoExtractor,
|
||||||
"#count" : 2,
|
"#count" : 2,
|
||||||
"#archive": False,
|
|
||||||
|
|
||||||
"filename" : "1514198129001376",
|
"filename" : str,
|
||||||
|
"extension": {"mp4", "m4a"},
|
||||||
"id" : "644342003942740",
|
"id" : "644342003942740",
|
||||||
"url" : str,
|
"url" : str,
|
||||||
"user_id" : "100064860875397",
|
"user_id" : "100064860875397",
|
||||||
|
|||||||
@@ -402,27 +402,31 @@ class TestPathfmt():
|
|||||||
|
|
||||||
class TestFormatter(formatter.StringFormatter):
|
class TestFormatter(formatter.StringFormatter):
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _noop(_):
|
|
||||||
return ""
|
|
||||||
|
|
||||||
def _apply_simple(self, key, fmt):
|
def _apply_simple(self, key, fmt):
|
||||||
if key == "extension" or "_parse_optional." in repr(fmt):
|
if key == "extension" or "_parse_optional." in repr(fmt):
|
||||||
return self._noop
|
def wrap(obj):
|
||||||
|
try:
|
||||||
def wrap(obj):
|
return fmt(obj[key])
|
||||||
return fmt(obj[key])
|
except KeyError:
|
||||||
|
return ""
|
||||||
|
else:
|
||||||
|
def wrap(obj):
|
||||||
|
return fmt(obj[key])
|
||||||
return wrap
|
return wrap
|
||||||
|
|
||||||
def _apply(self, key, funcs, fmt):
|
def _apply(self, key, funcs, fmt):
|
||||||
if key == "extension" or "_parse_optional." in repr(fmt):
|
if key == "extension" or "_parse_optional." in repr(fmt):
|
||||||
return self._noop
|
def wrap(obj):
|
||||||
|
obj = obj[key] if key in obj else ""
|
||||||
def wrap(obj):
|
for func in funcs:
|
||||||
obj = obj[key]
|
obj = func(obj)
|
||||||
for func in funcs:
|
return fmt(obj)
|
||||||
obj = func(obj)
|
else:
|
||||||
return fmt(obj)
|
def wrap(obj):
|
||||||
|
obj = obj[key]
|
||||||
|
for func in funcs:
|
||||||
|
obj = func(obj)
|
||||||
|
return fmt(obj)
|
||||||
return wrap
|
return wrap
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user