X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=test%2Ftest_utils.py;h=dd49a6d179dc7cea01935be7c019292b4f3559dc;hb=03ff2cc1c49c82daf2218b76e169c2d679447f03;hp=04f1bf283b32abe2421fb782f2765c3c95811c3c;hpb=4349c07dd7cd07620365b36093f0a148c41ce434;p=youtube-dl diff --git a/test/test_utils.py b/test/test_utils.py index 04f1bf283..dd49a6d17 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -16,38 +16,40 @@ import json import xml.etree.ElementTree from youtube_dl.utils import ( + args_to_str, clean_html, DateRange, + detect_exe_version, encodeFilename, + escape_rfc3986, + escape_url, find_xpath_attr, fix_xml_ampersands, - orderedSet, - OnDemandPagedList, InAdvancePagedList, + intlist_to_bytes, + js_to_json, + limit_length, + OnDemandPagedList, + orderedSet, parse_duration, + parse_filesize, + parse_iso8601, read_batch_urls, sanitize_filename, shell_quote, smuggle_url, str_to_int, + strip_jsonp, struct_unpack, timeconvert, unescapeHTML, unified_strdate, unsmuggle_url, + uppercase_escape, url_basename, urlencode_postdata, + version_tuple, xpath_with_ns, - parse_iso8601, - strip_jsonp, - uppercase_escape, - limit_length, - escape_rfc3986, - escape_url, - js_to_json, - intlist_to_bytes, - args_to_str, - parse_filesize, ) @@ -143,6 +145,9 @@ class TestUtil(unittest.TestCase): self.assertEqual(unified_strdate('2012/10/11 01:56:38 +0000'), '20121011') self.assertEqual(unified_strdate('1968-12-10'), '19681210') self.assertEqual(unified_strdate('28/01/2014 21:00:00 +0100'), '20140128') + self.assertEqual( + unified_strdate('11/26/2014 11:30:00 AM PST', day_first=False), + '20141126') def test_find_xpath_attr(self): testxml = ''' @@ -220,6 +225,9 @@ class TestUtil(unittest.TestCase): self.assertEqual(parse_duration('0s'), 0) self.assertEqual(parse_duration('01:02:03.05'), 3723.05) self.assertEqual(parse_duration('T30M38S'), 1838) + self.assertEqual(parse_duration('5 s'), 5) + self.assertEqual(parse_duration('3 min'), 180) + self.assertEqual(parse_duration('2.5 hours'), 9000) def test_fix_xml_ampersands(self): self.assertEqual( @@ -378,5 +386,21 @@ class TestUtil(unittest.TestCase): self.assertEqual(parse_filesize('1.2Tb'), 1200000000000) self.assertEqual(parse_filesize('1,24 KB'), 1240) + def test_version_tuple(self): + self.assertEqual(version_tuple('1'), (1,)) + self.assertEqual(version_tuple('10.23.344'), (10, 23, 344)) + self.assertEqual(version_tuple('10.1-6'), (10, 1, 6)) # avconv style + + def test_detect_exe_version(self): + self.assertEqual(detect_exe_version('''ffmpeg version 1.2.1 +built on May 27 2013 08:37:26 with gcc 4.7 (Debian 4.7.3-4) +configuration: --prefix=/usr --extra-'''), '1.2.1') + self.assertEqual(detect_exe_version('''ffmpeg version N-63176-g1fb4685 +built on May 15 2014 22:09:06 with gcc 4.8.2 (GCC)'''), 'N-63176-g1fb4685') + self.assertEqual(detect_exe_version('''X server found. dri2 connection failed! +Trying to open render node... +Success at /dev/dri/renderD128. +ffmpeg version 2.4.4 Copyright (c) 2000-2014 the FFmpeg ...'''), '2.4.4') + if __name__ == '__main__': unittest.main()