diff --git a/test/__init__.py b/test/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/helper.py b/test/helper.py deleted file mode 100644 index 6f2129eff..000000000 --- a/test/helper.py +++ /dev/null @@ -1,285 +0,0 @@ -from __future__ import unicode_literals - -import errno -import hashlib -import json -import os.path -import re -import ssl -import sys -import types -import unittest - -import youtube_dl.extractor -from youtube_dl import YoutubeDL -from youtube_dl.compat import ( - compat_open as open, - compat_os_name, - compat_str, -) -from youtube_dl.utils import ( - IDENTITY, - preferredencoding, - write_string, -) - - -def get_params(override=None): - PARAMETERS_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), - "parameters.json") - LOCAL_PARAMETERS_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), - "local_parameters.json") - with open(PARAMETERS_FILE, encoding='utf-8') as pf: - parameters = json.load(pf) - if os.path.exists(LOCAL_PARAMETERS_FILE): - with open(LOCAL_PARAMETERS_FILE, encoding='utf-8') as pf: - parameters.update(json.load(pf)) - if override: - parameters.update(override) - return parameters - - -def try_rm(filename): - """ Remove a file if it exists """ - try: - os.remove(filename) - except OSError as ose: - if ose.errno != errno.ENOENT: - raise - - -def report_warning(message): - ''' - Print the message to stderr, it will be prefixed with 'WARNING:' - If stderr is a tty file the 'WARNING:' will be colored - ''' - if sys.stderr.isatty() and compat_os_name != 'nt': - _msg_header = '\033[0;33mWARNING:\033[0m' - else: - _msg_header = 'WARNING:' - output = '%s %s\n' % (_msg_header, message) - if 'b' in getattr(sys.stderr, 'mode', '') or sys.version_info[0] < 3: - output = output.encode(preferredencoding()) - sys.stderr.write(output) - - -class FakeYDL(YoutubeDL): - def __init__(self, override=None): - # Different instances of the downloader can't share the same dictionary - # some test set the "sublang" parameter, which would break the md5 checks. - params = get_params(override=override) - super(FakeYDL, self).__init__(params, auto_init=False) - self.result = [] - - def to_screen(self, s, skip_eol=None): - print(s) - - def trouble(self, *args, **kwargs): - s = args[0] if len(args) > 0 else kwargs.get('message', 'Missing message') - raise Exception(s) - - def download(self, x): - self.result.append(x) - - def expect_warning(self, regex): - # Silence an expected warning matching a regex - old_report_warning = self.report_warning - - def report_warning(self, message): - if re.match(regex, message): - return - old_report_warning(message) - self.report_warning = types.MethodType(report_warning, self) - - -class FakeLogger(object): - def debug(self, msg): - pass - - def warning(self, msg): - pass - - def error(self, msg): - pass - - -def gettestcases(include_onlymatching=False): - for ie in youtube_dl.extractor.gen_extractors(): - for tc in ie.get_testcases(include_onlymatching): - yield tc - - -md5 = lambda s: hashlib.md5(s.encode('utf-8')).hexdigest() - - -def expect_value(self, got, expected, field): - if isinstance(expected, compat_str) and expected.startswith('re:'): - match_str = expected[len('re:'):] - match_rex = re.compile(match_str) - - self.assertTrue( - isinstance(got, compat_str), - 'Expected a %s object, but got %s for field %s' % ( - compat_str.__name__, type(got).__name__, field)) - self.assertTrue( - match_rex.match(got), - 'field %s (value: %r) should match %r' % (field, got, match_str)) - elif isinstance(expected, compat_str) and expected.startswith('startswith:'): - start_str = expected[len('startswith:'):] - self.assertTrue( - isinstance(got, compat_str), - 'Expected a %s object, but got %s for field %s' % ( - compat_str.__name__, type(got).__name__, field)) - self.assertTrue( - got.startswith(start_str), - 'field %s (value: %r) should start with %r' % (field, got, start_str)) - elif isinstance(expected, compat_str) and expected.startswith('contains:'): - contains_str = expected[len('contains:'):] - self.assertTrue( - isinstance(got, compat_str), - 'Expected a %s object, but got %s for field %s' % ( - compat_str.__name__, type(got).__name__, field)) - self.assertTrue( - contains_str in got, - 'field %s (value: %r) should contain %r' % (field, got, contains_str)) - elif isinstance(expected, compat_str) and re.match(r'lambda \w+:', expected): - fn = eval(expected) - suite = expected.split(':', 1)[1].strip() - self.assertTrue( - fn(got), - 'Expected field %s to meet condition %s, but value %r failed ' % (field, suite, got)) - elif isinstance(expected, type): - self.assertTrue( - isinstance(got, expected), - 'Expected type %r for field %s, but got value %r of type %r' % (expected, field, got, type(got))) - elif isinstance(expected, dict) and isinstance(got, dict): - expect_dict(self, got, expected) - elif isinstance(expected, list) and isinstance(got, list): - self.assertEqual( - len(expected), len(got), - 'Expected a list of length %d, but got a list of length %d for field %s' % ( - len(expected), len(got), field)) - for index, (item_got, item_expected) in enumerate(zip(got, expected)): - type_got = type(item_got) - type_expected = type(item_expected) - self.assertEqual( - type_expected, type_got, - 'Type mismatch for list item at index %d for field %s, expected %r, got %r' % ( - index, field, type_expected, type_got)) - expect_value(self, item_got, item_expected, field) - else: - if isinstance(expected, compat_str) and expected.startswith('md5:'): - self.assertTrue( - isinstance(got, compat_str), - 'Expected field %s to be a unicode object, but got value %r of type %r' % (field, got, type(got))) - got = 'md5:' + md5(got) - elif isinstance(expected, compat_str) and re.match(r'^(?:min|max)?count:\d+', expected): - self.assertTrue( - isinstance(got, (list, dict)), - 'Expected field %s to be a list or a dict, but it is of type %s' % ( - field, type(got).__name__)) - op, _, expected_num = expected.partition(':') - expected_num = int(expected_num) - if op == 'mincount': - assert_func = self.assertGreaterEqual - msg_tmpl = 'Expected %d items in field %s, but only got %d' - elif op == 'maxcount': - assert_func = self.assertLessEqual - msg_tmpl = 'Expected maximum %d items in field %s, but got %d' - elif op == 'count': - assert_func = self.assertEqual - msg_tmpl = 'Expected exactly %d items in field %s, but got %d' - else: - assert False - assert_func( - len(got), expected_num, - msg_tmpl % (expected_num, field, len(got))) - return - self.assertEqual( - expected, got, - 'Invalid value for field %s, expected %r, got %r' % (field, expected, got)) - - -def expect_dict(self, got_dict, expected_dict): - for info_field, expected in expected_dict.items(): - got = got_dict.get(info_field) - expect_value(self, got, expected, info_field) - - -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'): - 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']: - self.assertTrue(got_dict.get(key), 'Missing field: %s' % key) - - # Are checkable fields missing from the test case definition? - test_info_dict = dict((key, value if not isinstance(value, compat_str) or len(value) < 250 else 'md5:' + md5(value)) - for key, value in got_dict.items() - if value and key in ('id', 'title', 'description', 'uploader', 'upload_date', 'timestamp', 'uploader_id', 'location', 'age_limit')) - missing_keys = set(test_info_dict.keys()) - set(expected_dict.keys()) - if missing_keys: - def _repr(v): - if isinstance(v, compat_str): - return "'%s'" % v.replace('\\', '\\\\').replace("'", "\\'").replace('\n', '\\n') - else: - return repr(v) - info_dict_str = '' - if len(missing_keys) != len(expected_dict): - info_dict_str += ''.join( - ' %s: %s,\n' % (_repr(k), _repr(v)) - for k, v in test_info_dict.items() if k not in missing_keys) - - if info_dict_str: - info_dict_str += '\n' - info_dict_str += ''.join( - ' %s: %s,\n' % (_repr(k), _repr(test_info_dict[k])) - for k in missing_keys) - write_string( - '\n\'info_dict\': {\n' + info_dict_str + '},\n', out=sys.stderr) - self.assertFalse( - missing_keys, - 'Missing keys in test definition: %s' % ( - ', '.join(sorted(missing_keys)))) - - -def assertRegexpMatches(self, text, regexp, msg=None): - if hasattr(self, 'assertRegexp'): - return self.assertRegexp(text, regexp, msg) - else: - m = re.match(regexp, text) - if not m: - note = 'Regexp didn\'t match: %r not found' % (regexp) - if len(text) < 1000: - note += ' in %r' % text - if msg is None: - msg = note - else: - msg = note + ', ' + msg - self.assertTrue(m, msg) - - -def expect_warnings(ydl, warnings_re): - real_warning = ydl.report_warning - - def _report_warning(w): - if not any(re.search(w_re, w) for w_re in warnings_re): - real_warning(w) - - ydl.report_warning = _report_warning - - -def http_server_port(httpd): - if os.name == 'java' and isinstance(httpd.socket, ssl.SSLSocket): - # In Jython SSLSocket is not a subclass of socket.socket - sock = httpd.socket.sock - else: - sock = httpd.socket - return sock.getsockname()[1] - - -def expectedFailureIf(cond): - return unittest.expectedFailure if cond else IDENTITY diff --git a/test/parameters.json b/test/parameters.json deleted file mode 100644 index 864c9d130..000000000 --- a/test/parameters.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "consoletitle": false, - "continuedl": true, - "forcedescription": false, - "forcefilename": false, - "forceformat": false, - "forcethumbnail": false, - "forcetitle": false, - "forceurl": false, - "format": "best", - "ignoreerrors": false, - "listformats": null, - "logtostderr": false, - "matchtitle": null, - "max_downloads": null, - "nooverwrites": false, - "nopart": false, - "noprogress": false, - "outtmpl": "%(id)s.%(ext)s", - "password": null, - "playliststart": 1, - "prefer_free_formats": false, - "quiet": false, - "ratelimit": null, - "rejecttitle": null, - "retries": 10, - "simulate": false, - "subtitleslang": null, - "subtitlesformat": "best", - "test": true, - "updatetime": true, - "usenetrc": false, - "username": null, - "verbose": true, - "writedescription": false, - "writeinfojson": true, - "writesubtitles": false, - "allsubtitles": false, - "listsubtitles": false, - "socket_timeout": 20, - "fixup": "never" -} diff --git a/test/swftests/.gitignore b/test/swftests/.gitignore deleted file mode 100644 index da97ff7ca..000000000 --- a/test/swftests/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.swf diff --git a/test/swftests/ArrayAccess.as b/test/swftests/ArrayAccess.as deleted file mode 100644 index e22caa386..000000000 --- a/test/swftests/ArrayAccess.as +++ /dev/null @@ -1,19 +0,0 @@ -// input: [["a", "b", "c", "d"]] -// output: ["c", "b", "a", "d"] - -package { -public class ArrayAccess { - public static function main(ar:Array):Array { - var aa:ArrayAccess = new ArrayAccess(); - return aa.f(ar, 2); - } - - private function f(ar:Array, num:Number):Array{ - var x:String = ar[0]; - var y:String = ar[num % ar.length]; - ar[0] = y; - ar[num] = x; - return ar; - } -} -} diff --git a/test/swftests/ClassCall.as b/test/swftests/ClassCall.as deleted file mode 100644 index aef58daf3..000000000 --- a/test/swftests/ClassCall.as +++ /dev/null @@ -1,17 +0,0 @@ -// input: [] -// output: 121 - -package { -public class ClassCall { - public static function main():int{ - var f:OtherClass = new OtherClass(); - return f.func(100,20); - } -} -} - -class OtherClass { - public function func(x: int, y: int):int { - return x+y+1; - } -} diff --git a/test/swftests/ClassConstruction.as b/test/swftests/ClassConstruction.as deleted file mode 100644 index 436479f8f..000000000 --- a/test/swftests/ClassConstruction.as +++ /dev/null @@ -1,15 +0,0 @@ -// input: [] -// output: 0 - -package { -public class ClassConstruction { - public static function main():int{ - var f:Foo = new Foo(); - return 0; - } -} -} - -class Foo { - -} diff --git a/test/swftests/ConstArrayAccess.as b/test/swftests/ConstArrayAccess.as deleted file mode 100644 index 07dc3f460..000000000 --- a/test/swftests/ConstArrayAccess.as +++ /dev/null @@ -1,18 +0,0 @@ -// input: [] -// output: 4 - -package { -public class ConstArrayAccess { - private static const x:int = 2; - private static const ar:Array = ["42", "3411"]; - - public static function main():int{ - var c:ConstArrayAccess = new ConstArrayAccess(); - return c.f(); - } - - public function f(): int { - return ar[1].length; - } -} -} diff --git a/test/swftests/ConstantInt.as b/test/swftests/ConstantInt.as deleted file mode 100644 index e0bbb6166..000000000 --- a/test/swftests/ConstantInt.as +++ /dev/null @@ -1,12 +0,0 @@ -// input: [] -// output: 2 - -package { -public class ConstantInt { - private static const x:int = 2; - - public static function main():int{ - return x; - } -} -} diff --git a/test/swftests/DictCall.as b/test/swftests/DictCall.as deleted file mode 100644 index c2d174cc2..000000000 --- a/test/swftests/DictCall.as +++ /dev/null @@ -1,10 +0,0 @@ -// input: [{"x": 1, "y": 2}] -// output: 3 - -package { -public class DictCall { - public static function main(d:Object):int{ - return d.x + d.y; - } -} -} diff --git a/test/swftests/EqualsOperator.as b/test/swftests/EqualsOperator.as deleted file mode 100644 index 837a69a46..000000000 --- a/test/swftests/EqualsOperator.as +++ /dev/null @@ -1,10 +0,0 @@ -// input: [] -// output: false - -package { -public class EqualsOperator { - public static function main():Boolean{ - return 1 == 2; - } -} -} diff --git a/test/swftests/LocalVars.as b/test/swftests/LocalVars.as deleted file mode 100644 index b2911a9f3..000000000 --- a/test/swftests/LocalVars.as +++ /dev/null @@ -1,13 +0,0 @@ -// input: [1, 2] -// output: 3 - -package { -public class LocalVars { - public static function main(a:int, b:int):int{ - var c:int = a + b + b; - var d:int = c - b; - var e:int = d; - return e; - } -} -} diff --git a/test/swftests/MemberAssignment.as b/test/swftests/MemberAssignment.as deleted file mode 100644 index dcba5e3ff..000000000 --- a/test/swftests/MemberAssignment.as +++ /dev/null @@ -1,22 +0,0 @@ -// input: [1] -// output: 2 - -package { -public class MemberAssignment { - public var v:int; - - public function g():int { - return this.v; - } - - public function f(a:int):int{ - this.v = a; - return this.v + this.g(); - } - - public static function main(a:int): int { - var v:MemberAssignment = new MemberAssignment(); - return v.f(a); - } -} -} diff --git a/test/swftests/NeOperator.as b/test/swftests/NeOperator.as deleted file mode 100644 index 61dcbc4e9..000000000 --- a/test/swftests/NeOperator.as +++ /dev/null @@ -1,24 +0,0 @@ -// input: [] -// output: 123 - -package { -public class NeOperator { - public static function main(): int { - var res:int = 0; - if (1 != 2) { - res += 3; - } else { - res += 4; - } - if (2 != 2) { - res += 10; - } else { - res += 20; - } - if (9 == 9) { - res += 100; - } - return res; - } -} -} diff --git a/test/swftests/PrivateCall.as b/test/swftests/PrivateCall.as deleted file mode 100644 index f1c110a37..000000000 --- a/test/swftests/PrivateCall.as +++ /dev/null @@ -1,21 +0,0 @@ -// input: [] -// output: 9 - -package { -public class PrivateCall { - public static function main():int{ - var f:OtherClass = new OtherClass(); - return f.func(); - } -} -} - -class OtherClass { - private function pf():int { - return 9; - } - - public function func():int { - return this.pf(); - } -} diff --git a/test/swftests/PrivateVoidCall.as b/test/swftests/PrivateVoidCall.as deleted file mode 100644 index 2cc016797..000000000 --- a/test/swftests/PrivateVoidCall.as +++ /dev/null @@ -1,22 +0,0 @@ -// input: [] -// output: 9 - -package { -public class PrivateVoidCall { - public static function main():int{ - var f:OtherClass = new OtherClass(); - f.func(); - return 9; - } -} -} - -class OtherClass { - private function pf():void { - ; - } - - public function func():void { - this.pf(); - } -} diff --git a/test/swftests/StaticAssignment.as b/test/swftests/StaticAssignment.as deleted file mode 100644 index b061c219d..000000000 --- a/test/swftests/StaticAssignment.as +++ /dev/null @@ -1,13 +0,0 @@ -// input: [1] -// output: 1 - -package { -public class StaticAssignment { - public static var v:int; - - public static function main(a:int):int{ - v = a; - return v; - } -} -} diff --git a/test/swftests/StaticRetrieval.as b/test/swftests/StaticRetrieval.as deleted file mode 100644 index c8352d819..000000000 --- a/test/swftests/StaticRetrieval.as +++ /dev/null @@ -1,16 +0,0 @@ -// input: [] -// output: 1 - -package { -public class StaticRetrieval { - public static var v:int; - - public static function main():int{ - if (v) { - return 0; - } else { - return 1; - } - } -} -} diff --git a/test/swftests/StringBasics.as b/test/swftests/StringBasics.as deleted file mode 100644 index d27430b13..000000000 --- a/test/swftests/StringBasics.as +++ /dev/null @@ -1,11 +0,0 @@ -// input: [] -// output: 3 - -package { -public class StringBasics { - public static function main():int{ - var s:String = "abc"; - return s.length; - } -} -} diff --git a/test/swftests/StringCharCodeAt.as b/test/swftests/StringCharCodeAt.as deleted file mode 100644 index c20d74d65..000000000 --- a/test/swftests/StringCharCodeAt.as +++ /dev/null @@ -1,11 +0,0 @@ -// input: [] -// output: 9897 - -package { -public class StringCharCodeAt { - public static function main():int{ - var s:String = "abc"; - return s.charCodeAt(1) * 100 + s.charCodeAt(); - } -} -} diff --git a/test/swftests/StringConversion.as b/test/swftests/StringConversion.as deleted file mode 100644 index c976f5042..000000000 --- a/test/swftests/StringConversion.as +++ /dev/null @@ -1,11 +0,0 @@ -// input: [] -// output: 2 - -package { -public class StringConversion { - public static function main():int{ - var s:String = String(99); - return s.length; - } -} -} diff --git a/test/test_InfoExtractor.py b/test/test_InfoExtractor.py deleted file mode 100644 index 09100a1d6..000000000 --- a/test/test_InfoExtractor.py +++ /dev/null @@ -1,1407 +0,0 @@ -#!/usr/bin/env python - -from __future__ import unicode_literals - -# Allow direct execution -import os -import sys -import unittest - -sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) - -import threading - -from test.helper import ( - expect_dict, - expect_value, - FakeYDL, - http_server_port, -) -from youtube_dl.compat import ( - compat_etree_fromstring, - compat_http_server, - compat_open as open, -) -from youtube_dl.extractor.common import InfoExtractor -from youtube_dl.extractor import ( - get_info_extractor, - YoutubeIE, -) -from youtube_dl.utils import ( - encode_data_uri, - ExtractorError, - RegexNotFoundError, - strip_jsonp, -) - - -TEAPOT_RESPONSE_STATUS = 418 -TEAPOT_RESPONSE_BODY = "

418 I'm a teapot

" - - -class InfoExtractorTestRequestHandler(compat_http_server.BaseHTTPRequestHandler): - def log_message(self, format, *args): - pass - - def do_GET(self): - if self.path == '/teapot': - self.send_response(TEAPOT_RESPONSE_STATUS) - self.send_header('Content-Type', 'text/html; charset=utf-8') - self.end_headers() - self.wfile.write(TEAPOT_RESPONSE_BODY.encode()) - else: - assert False - - -class DummyIE(InfoExtractor): - pass - - -class TestInfoExtractor(unittest.TestCase): - def setUp(self): - self.ie = DummyIE(FakeYDL()) - - def test_ie_key(self): - self.assertEqual(get_info_extractor(YoutubeIE.ie_key()), YoutubeIE) - - def test_html_search_regex(self): - html = '

Watch this video

' - search = lambda re, *args: self.ie._html_search_regex(re, html, *args) - self.assertEqual(search(r'

(.+?)

', 'foo'), 'Watch this video') - - def test_opengraph(self): - ie = self.ie - html = ''' - - - - - - - - - - ''' - self.assertEqual(ie._og_search_title(html), 'Foo') - self.assertEqual(ie._og_search_description(html), 'Some video\'s description ') - self.assertEqual(ie._og_search_thumbnail(html), 'http://domain.com/pic.jpg?key1=val1&key2=val2') - self.assertEqual(ie._og_search_video_url(html, default=None), None) - self.assertEqual(ie._og_search_property('foobar', html), 'Foo') - self.assertEqual(ie._og_search_property('test1', html), 'foo > < bar') - self.assertEqual(ie._og_search_property('test2', html), 'foo >//< bar') - self.assertEqual(ie._og_search_property('test3', html), 'Ill-formatted opengraph') - self.assertEqual(ie._og_search_property(('test0', 'test1'), html), 'foo > < bar') - self.assertRaises(RegexNotFoundError, ie._og_search_property, 'test0', html, None, fatal=True) - self.assertRaises(RegexNotFoundError, ie._og_search_property, ('test0', 'test00'), html, None, fatal=True) - self.assertEqual(ie._og_search_property('test4', html), 'unquoted-value') - - def test_html_search_meta(self): - ie = self.ie - html = ''' - - - - - - - ''' - - self.assertEqual(ie._html_search_meta('a', html), '1') - self.assertEqual(ie._html_search_meta('b', html), '2') - self.assertEqual(ie._html_search_meta('c', html), '3') - self.assertEqual(ie._html_search_meta('d', html), '4') - self.assertEqual(ie._html_search_meta('e', html), '5') - self.assertEqual(ie._html_search_meta('f', html), '6') - self.assertEqual(ie._html_search_meta(('a', 'b', 'c'), html), '1') - self.assertEqual(ie._html_search_meta(('c', 'b', 'a'), html), '3') - self.assertEqual(ie._html_search_meta(('z', 'x', 'c'), html), '3') - self.assertRaises(RegexNotFoundError, ie._html_search_meta, 'z', html, None, fatal=True) - self.assertRaises(RegexNotFoundError, ie._html_search_meta, ('z', 'x'), html, None, fatal=True) - - def test_search_nextjs_data(self): - html = ''' - - - - - - Test _search_nextjs_data() - - -
-
-
-
-
-
-
-
-
-
-
- -
-
-
- - - -''' - search = self.ie._search_nextjs_data(html, 'testID') - self.assertEqual(search['props']['pageProps']['video']['id'], 'testid') - search = self.ie._search_nextjs_data( - 'no next.js data here, move along', 'testID', default={'status': 0}) - self.assertEqual(search['status'], 0) - - def test_search_nuxt_data(self): - html = ''' - - - - - Nuxt.js Test Page - - - - -
-

Example heading

-
-

Decoy text

-
-
- - - - -''' - search = self.ie._search_nuxt_data(html, 'testID') - self.assertEqual(search['track']['id'], 'testid') - - def test_search_json_ld_realworld(self): - # https://github.com/ytdl-org/youtube-dl/issues/23306 - expect_dict( - self, - self.ie._search_json_ld(r'''''', None), - { - 'title': '1 On 1 With Kleio', - 'description': 'Kleio Valentien', - 'url': 'https://gvideo.eporner.com/xN49A1cT3eB/xN49A1cT3eB.mp4', - 'timestamp': 1449347075, - 'duration': 743.0, - 'view_count': 1120958, - 'width': 1920, - 'height': 1080, - }) - - def test_download_json(self): - uri = encode_data_uri(b'{"foo": "blah"}', 'application/json') - self.assertEqual(self.ie._download_json(uri, None), {'foo': 'blah'}) - uri = encode_data_uri(b'callback({"foo": "blah"})', 'application/javascript') - self.assertEqual(self.ie._download_json(uri, None, transform_source=strip_jsonp), {'foo': 'blah'}) - uri = encode_data_uri(b'{"foo": invalid}', 'application/json') - self.assertRaises(ExtractorError, self.ie._download_json, uri, None) - self.assertEqual(self.ie._download_json(uri, None, fatal=False), None) - - def test_parse_html5_media_entries(self): - # inline video tag - expect_dict( - self, - self.ie._parse_html5_media_entries( - 'https://127.0.0.1/video.html', - r'