]> jfr.im git - yt-dlp.git/blame - test/test_unicode_literals.py
[test/test_utils] Fix typo in method name
[yt-dlp.git] / test / test_unicode_literals.py
CommitLineData
6febd1c1
PH
1from __future__ import unicode_literals
2
3import io
4import os
5import re
6import unittest
7
8rootDir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
9
01c62591
PH
10IGNORED_FILES = [
11 'setup.py', # http://bugs.python.org/issue13943
12]
13
6febd1c1
PH
14
15class TestUnicodeLiterals(unittest.TestCase):
16 def test_all_files(self):
28ab2e48 17 print('Skipping this test (not yet fully implemented)')
6febd1c1
PH
18 return
19
20 for dirpath, _, filenames in os.walk(rootDir):
21 for basename in filenames:
22 if not basename.endswith('.py'):
23 continue
01c62591
PH
24 if basename in IGNORED_FILES:
25 continue
26
6febd1c1
PH
27 fn = os.path.join(dirpath, basename)
28 with io.open(fn, encoding='utf-8') as inf:
29 code = inf.read()
30
31 if "'" not in code and '"' not in code:
32 continue
33 imps = 'from __future__ import unicode_literals'
34 self.assertTrue(
35 imps in code,
36 ' %s missing in %s' % (imps, fn))
37
38 m = re.search(r'(?<=\s)u[\'"](?!\)|,|$)', code)
39 if m is not None:
40 self.assertTrue(
41 m is None,
42 'u present in %s, around %s' % (
43 fn, code[m.start() - 10:m.end() + 10]))
44
45
46if __name__ == '__main__':
47 unittest.main()