X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=test%2Ftest_utils.py;h=51eb0b6b936c7ea5d21cfef9bdc0b70f2ee7663a;hb=d82ba23ba52e217c22df9ff20bf176dc6c72879a;hp=e920d661f6e520afcc4bcb0308e7faac2370e92a;hpb=ce328530a9009ffb5f0f486fc5178520d972f07a;p=youtube-dl diff --git a/test/test_utils.py b/test/test_utils.py index e920d661f..51eb0b6b9 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -10,6 +10,7 @@ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) # Various small unit tests import io +import json import xml.etree.ElementTree #from youtube_dl.utils import htmlentity_transform @@ -36,6 +37,8 @@ from youtube_dl.utils import ( urlencode_postdata, xpath_with_ns, parse_iso8601, + strip_jsonp, + uppercase_escape, ) if sys.version_info < (3, 0): @@ -272,5 +275,14 @@ class TestUtil(unittest.TestCase): self.assertEqual(parse_iso8601('2014-03-23T22:04:26+0000'), 1395612266) self.assertEqual(parse_iso8601('2014-03-23T22:04:26Z'), 1395612266) + def test_strip_jsonp(self): + stripped = strip_jsonp('cb ([ {"id":"532cb",\n\n\n"x":\n3}\n]\n);') + d = json.loads(stripped) + self.assertEqual(d, [{"id": "532cb", "x": 3}]) + + def test_uppercase_escpae(self): + self.assertEqual(uppercase_escape(u'aä'), u'aä') + self.assertEqual(uppercase_escape(u'\\U0001d550'), u'𝕐') + if __name__ == '__main__': unittest.main()