]>
Raphaƫl G. Git Repositories - youtubedl/blob - test/test_unicode_literals.py
7f816698e7b2e20bc982b0eeb9638885edf19b48
1 from __future__
import unicode_literals
3 # Allow direct execution
7 sys
.path
.insert(0, os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
))))
12 rootDir
= os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
)))
15 'setup.py', # http://bugs.python.org/issue13943
21 from test
.helper
import assertRegexpMatches
24 class TestUnicodeLiterals(unittest
.TestCase
):
25 def test_all_files(self
):
26 for dirpath
, _
, filenames
in os
.walk(rootDir
):
27 for basename
in filenames
:
28 if not basename
.endswith('.py'):
30 if basename
in IGNORED_FILES
:
33 fn
= os
.path
.join(dirpath
, basename
)
34 with io
.open(fn
, encoding
='utf-8') as inf
:
37 if "'" not in code
and '"' not in code
:
42 r
'(?:(?:#.*?|\s*)\n)*from __future__ import (?:[a-z_]+,\s*)*unicode_literals',
43 'unicode_literals import missing in %s' % fn
)
45 m
= re
.search(r
'(?<=\s)u[\'"](?!\)|,|$)', code)
49 'u present in %s, around %s' % (
50 fn, code[m.start() - 10:m.end() + 10]))
53 if __name__ == '__main__':