]>
Raphaël G. Git Repositories - youtubedl/blob - test/test_compat.py
1eb454e068970eb1a0d48cc3cd881e0bf71f9463
4 from __future__
import unicode_literals
6 # Allow direct execution
10 sys
.path
.insert(0, os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
))))
13 from youtube_dl
.utils
import get_filesystem_encoding
14 from youtube_dl
.compat
import (
20 class TestCompat(unittest
.TestCase
):
21 def test_compat_getenv(self
):
23 os
.environ
['YOUTUBE-DL-TEST'] = (
24 test_str
if sys
.version_info
>= (3, 0)
25 else test_str
.encode(get_filesystem_encoding()))
26 self
.assertEqual(compat_getenv('YOUTUBE-DL-TEST'), test_str
)
28 def test_compat_expanduser(self
):
29 old_home
= os
.environ
.get('HOME')
30 test_str
= 'C:\Documents and Settings\тест\Application Data'
31 os
.environ
['HOME'] = (
32 test_str
if sys
.version_info
>= (3, 0)
33 else test_str
.encode(get_filesystem_encoding()))
34 self
.assertEqual(compat_expanduser('~'), test_str
)
35 os
.environ
['HOME'] = old_home
37 def test_all_present(self
):
38 import youtube_dl
.compat
39 all_names
= youtube_dl
.compat
.__all
__
40 present_names
= set(filter(
41 lambda c
: '_' in c
and not c
.startswith('_'),
42 dir(youtube_dl
.compat
))) - set(['unicode_literals'])
43 self
.assertEqual(all_names
, sorted(present_names
))
45 if __name__
== '__main__':