X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=test%2Ftest_utils.py;h=80c765bc496f0ce51e3deda0b39689f8136b597a;hb=b3a286d69d2bf28ba32a77b0fe66932eb6d1bc65;hp=ebec7986f2b660da01db37c04bb65ccc283884bd;hpb=d4f64cabf4ede444b390bb71b90ad4103ce572c0;p=youtube-dl.git diff --git a/test/test_utils.py b/test/test_utils.py index ebec7986f..80c765bc4 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -156,6 +156,9 @@ class TestUtil(unittest.TestCase): self.assertEqual( unified_strdate('11/26/2014 11:30:00 AM PST', day_first=False), '20141126') + self.assertEqual( + unified_strdate('2/2/2015 6:47:40 PM', day_first=False), + '20150202') def test_find_xpath_attr(self): testxml = ''' @@ -238,6 +241,8 @@ class TestUtil(unittest.TestCase): self.assertEqual(parse_duration('5 s'), 5) self.assertEqual(parse_duration('3 min'), 180) self.assertEqual(parse_duration('2.5 hours'), 9000) + self.assertEqual(parse_duration('02:03:04'), 7384) + self.assertEqual(parse_duration('01:02:03:04'), 93784) def test_fix_xml_ampersands(self): self.assertEqual( @@ -371,6 +376,16 @@ class TestUtil(unittest.TestCase): on = js_to_json('{"abc": true}') self.assertEqual(json.loads(on), {'abc': True}) + # Ignore JavaScript code as well + on = js_to_json('''{ + "x": 1, + y: "a", + z: some.code + }''') + d = json.loads(on) + self.assertEqual(d['x'], 1) + self.assertEqual(d['y'], 'a') + def test_clean_html(self): self.assertEqual(clean_html('a:\nb'), 'a: b') self.assertEqual(clean_html('a:\n "b"'), 'a: "b"')