aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorgcmalloc <gcmalloc@gmail.com>2012-09-28 14:47:01 +0200
committergcmalloc <gcmalloc@gmail.com>2012-10-12 20:24:58 +0200
commit44fb345437553801184377dde05cc8a312fd2da2 (patch)
tree1fce0e492724b45f4e890b93a6622f681c2daeb1 /test
parent9993976ae436c62ef86c2c45f0f001e5f7e471bd (diff)
adding TestCase class and corresponding test
Diffstat (limited to 'test')
-rw-r--r--test/test_utils.py51
1 files changed, 38 insertions, 13 deletions
diff --git a/test/test_utils.py b/test/test_utils.py
index 614ef1b03..d4b4cb920 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -2,22 +2,47 @@
# Various small unit tests
+import unittest
+
+#from youtube_dl.utils import htmlentity_transform
+from youtube_dl.utils import timeconvert
from youtube_dl.utils import sanitize_filename
+from youtube_dl.utils import unescapeHTML
+from youtube_dl.utils import orderedSet
+
+
+class TestUtil(unittest.TestCase):
+ def test_timeconvert(self):
+ self.assertIsNone(timeconvert(''))
+ self.assertIsNone(timeconvert('bougrg'))
+
+ def test_sanitize_filename(self):
+ self.assertEqual(sanitize_filename(u'abc'), u'abc')
+ self.assertEqual(sanitize_filename(u'abc_d-e'), u'abc_d-e')
+
+ self.assertEqual(sanitize_filename(u'123'), u'123')
+
+ self.assertNotIn(u'/', sanitize_filename(u'abc/de'))
+ self.assertNotIn(u'abc', sanitize_filename(u'abc/de'))
+ self.assertIn(u'de', sanitize_filename(u'abc/de'))
+ self.assertNotIn(u'/', sanitize_filename(u'abc/de///'))
+
+ self.assertIn(u'\\', sanitize_filename(u'abc\\de'))
+ self.assertIn(u'abc', sanitize_filename(u'abc\\de'))
+ self.assertIn(u'de', sanitize_filename(u'abc\\de'))
-def test_sanitize_filename():
- assert sanitize_filename(u'abc') == u'abc'
- assert sanitize_filename(u'abc_d-e') == u'abc_d-e'
+ self.assertEqual(sanitize_filename(u'ä'), u'ä')
+ self.assertEqual(sanitize_filename(u'кириллица'), u'кириллица')
- assert sanitize_filename(u'123') == u'123'
+ def test_ordered_set(self):
+ self.assertEqual(orderedSet([1,1,2,3,4,4,5,6,7,3,5]), [1,2,3,4,5,6,7])
+ self.assertEqual(orderedSet([]), [])
+ self.assertEqual(orderedSet([1]), [1])
+ #keep the list ordered
+ self.assertEqual(orderedSet([135,1,1,1]), [135,1])
- assert u'/' not in sanitize_filename(u'abc/de')
- assert u'abc' in sanitize_filename(u'abc/de')
- assert u'de' in sanitize_filename(u'abc/de')
- assert u'/' not in sanitize_filename(u'abc/de///')
+ def test_unescape_html(self):
+ self.assertEqual(unescapeHTML(u"%20;"), u"%20;")
+ self.assertEqual(unescapeHTML(u"gre&tre&yre"), [u'gre', u'tre', u'yre'])
- assert u'\\' not in sanitize_filename(u'abc\\de')
- assert u'abc' in sanitize_filename(u'abc\\de')
- assert u'de' in sanitize_filename(u'abc\\de')
- assert sanitize_filename(u'ä') == u'ä'
- assert sanitize_filename(u'кириллица') == u'кириллица'