[test_utils] Add tests for prepend_extension

This commit is contained in:
Sergey M․ 2015-05-02 23:10:48 +06:00
parent e65e4c8874
commit a4bcaad773
1 changed files with 9 additions and 0 deletions

View File

@ -41,6 +41,7 @@ from youtube_dl.utils import (
sanitize_filename, sanitize_filename,
sanitize_path, sanitize_path,
sanitize_url_path_consecutive_slashes, sanitize_url_path_consecutive_slashes,
prepend_extension,
shell_quote, shell_quote,
smuggle_url, smuggle_url,
str_to_int, str_to_int,
@ -193,6 +194,14 @@ class TestUtil(unittest.TestCase):
sanitize_url_path_consecutive_slashes('http://hostname/abc//'), sanitize_url_path_consecutive_slashes('http://hostname/abc//'),
'http://hostname/abc/') 'http://hostname/abc/')
def test_prepend_extension(self):
self.assertEqual(prepend_extension('abc.ext', 'temp'), 'abc.temp.ext')
self.assertEqual(prepend_extension('abc.ext', 'temp', 'ext'), 'abc.temp.ext')
self.assertEqual(prepend_extension('abc.unexpected_ext', 'temp', 'ext'), 'abc.unexpected_ext.temp')
self.assertEqual(prepend_extension('abc', 'temp'), 'abc.temp')
self.assertEqual(prepend_extension('.abc', 'temp'), '.abc.temp')
self.assertEqual(prepend_extension('.abc.ext', 'temp'), '.abc.temp.ext')
def test_ordered_set(self): 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([1, 1, 2, 3, 4, 4, 5, 6, 7, 3, 5]), [1, 2, 3, 4, 5, 6, 7])
self.assertEqual(orderedSet([]), []) self.assertEqual(orderedSet([]), [])