Skip to content

Commit

Permalink
First tests
Browse files Browse the repository at this point in the history
  • Loading branch information
phihag committed Nov 21, 2011
1 parent cb6568b commit e33e304
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/test_div.py
Original file line number Diff line number Diff line change
@@ -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')

2 changes: 2 additions & 0 deletions youtube-dl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions youtube_dl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit e33e304

Please sign in to comment.