]>
Raphaƫl G. Git Repositories - youtubedl/blob - test/test_unicode_literals.py
1 from __future__
import unicode_literals
8 rootDir
= os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
)))
11 'setup.py', # http://bugs.python.org/issue13943
17 class TestUnicodeLiterals(unittest
.TestCase
):
18 def test_all_files(self
):
19 for dirpath
, _
, filenames
in os
.walk(rootDir
):
20 for basename
in filenames
:
21 if not basename
.endswith('.py'):
23 if basename
in IGNORED_FILES
:
26 fn
= os
.path
.join(dirpath
, basename
)
27 with io
.open(fn
, encoding
='utf-8') as inf
:
30 if "'" not in code
and '"' not in code
:
32 self
.assertRegexpMatches(
34 r
'(?:#.*\n*)?from __future__ import (?:[a-z_]+,\s*)*unicode_literals',
35 'unicode_literals import missing in %s' % fn
)
37 m
= re
.search(r
'(?<=\s)u[\'"](?!\)|,|$)', code)
41 'u present in %s, around %s' % (
42 fn, code[m.start() - 10:m.end() + 10]))
45 if __name__ == '__main__':