diff options
author | Philipp Hagemeister <phihag@phihag.de> | 2012-10-19 05:48:12 -0700 |
---|---|---|
committer | Philipp Hagemeister <phihag@phihag.de> | 2012-10-19 05:48:12 -0700 |
commit | 9248cb0549674ca78e1a51ebc98eb5c5a29876e8 (patch) | |
tree | 359fa4fe28601f43c77f1370e369338837acefdc /test/test_utils.py | |
parent | 902b2a0a45d397089807182354c34fbbd56719af (diff) | |
parent | 6b41b6111966400925dd648420f11704ac9dbbf2 (diff) |
Merge pull request #472 from gcmalloc/master
Test proposal
Diffstat (limited to 'test/test_utils.py')
-rw-r--r-- | test/test_utils.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/test_utils.py b/test/test_utils.py new file mode 100644 index 000000000..eb0af703f --- /dev/null +++ b/test/test_utils.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- + +# 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.assertTrue(timeconvert('') is None) + self.assertTrue(timeconvert('bougrg') is None) + + 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.assertEqual(u'abc_de', sanitize_filename(u'abc/de')) + self.assertTrue(u'de' in sanitize_filename(u'abc/de')) + self.assertFalse(u'/' in sanitize_filename(u'abc/de///')) + + self.assertEqual(u'abc_de', sanitize_filename(u'abc\\de')) + self.assertEqual(u'abc_de', sanitize_filename(u'abc\\de')) + self.assertTrue(u'de' in sanitize_filename(u'abc\\de')) + + self.assertEqual(sanitize_filename(u'ä'), u'ä') + self.assertEqual(sanitize_filename(u'кириллица'), u'кириллица') + + 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]) + + def test_unescape_html(self): + self.assertEqual(unescapeHTML(u"%20;"), u"%20;") |