]>
Commit | Line | Data |
---|---|---|
1 | #!/usr/bin/env python | |
2 | # coding: utf-8 | |
3 | ||
4 | from __future__ import unicode_literals | |
5 | ||
6 | # Allow direct execution | |
7 | import os | |
8 | import sys | |
9 | import unittest | |
10 | sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | |
11 | ||
12 | ||
13 | from youtube_dl.utils import get_filesystem_encoding | |
14 | from youtube_dl.compat import ( | |
15 | compat_getenv, | |
16 | compat_expanduser, | |
17 | ) | |
18 | ||
19 | ||
20 | class TestCompat(unittest.TestCase): | |
21 | def test_compat_getenv(self): | |
22 | test_str = 'тест' | |
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) | |
27 | ||
28 | def test_compat_expanduser(self): | |
29 | test_str = 'C:\Documents and Settings\тест\Application Data' | |
30 | os.environ['HOME'] = ( | |
31 | test_str if sys.version_info >= (3, 0) | |
32 | else test_str.encode(get_filesystem_encoding())) | |
33 | self.assertEqual(compat_expanduser('~'), test_str) | |
34 | ||
35 | def test_all_present(self): | |
36 | import youtube_dl.compat | |
37 | all_names = youtube_dl.compat.__all__ | |
38 | present_names = set(filter( | |
39 | lambda c: '_' in c and not c.startswith('_'), | |
40 | dir(youtube_dl.compat))) | |
41 | self.assertEqual(all_names, sorted(present_names)) | |
42 | ||
43 | if __name__ == '__main__': | |
44 | unittest.main() |