First tests
authorPhilipp Hagemeister <phihag@phihag.de>
Mon, 21 Nov 2011 19:07:24 +0000 (20:07 +0100)
committerPhilipp Hagemeister <phihag@phihag.de>
Mon, 21 Nov 2011 19:07:24 +0000 (20:07 +0100)
test/test_div.py [new file with mode: 0644]
youtube-dl
youtube_dl/__init__.py

diff --git a/test/test_div.py b/test/test_div.py
new file mode 100644 (file)
index 0000000..367780e
--- /dev/null
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+
+# Various small unit tests
+
+import os,sys
+sys.path.append(os.path.dirname(os.path.dirname(__file__)))
+
+import youtube_dl
+
+def test_simplify_title():
+       assert youtube_dl._simplify_title('abc') == 'abc'
+       assert youtube_dl._simplify_title('abc_d-e') == 'abc_d-e'
+
+       assert '/' not in youtube_dl._simplify_title('abc/de')
+       assert 'abc' in youtube_dl._simplify_title('abc/de')
+       assert 'de' in youtube_dl._simplify_title('abc/de')
+
+       assert '\\' not in youtube_dl._simplify_title('abc\\de')
+       assert 'abc' in youtube_dl._simplify_title('abc\\de')
+       assert 'de' in youtube_dl._simplify_title('abc\\de')
+
index a5af555ff1471630f72853bb3c97cd6cfe7c6990..8fc320cbf73890aff89de3a9f93aaa823007335e 100755 (executable)
@@ -279,6 +279,8 @@ def timeconvert(timestr):
                timestamp = email.utils.mktime_tz(timetuple)
        return timestamp
 
+def _simplify_title(title):
+       return re.sub(ur'[^\w\d_\-]+', u'_', title)
 
 class DownloadError(Exception):
        """Download Error exception.
index a5af555ff1471630f72853bb3c97cd6cfe7c6990..8fc320cbf73890aff89de3a9f93aaa823007335e 100755 (executable)
@@ -279,6 +279,8 @@ def timeconvert(timestr):
                timestamp = email.utils.mktime_tz(timetuple)
        return timestamp
 
+def _simplify_title(title):
+       return re.sub(ur'[^\w\d_\-]+', u'_', title)
 
 class DownloadError(Exception):
        """Download Error exception.