]>
Raphaƫl G. Git Repositories - youtubedl/blob - test/test_unicode_literals.py
   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 
  25 from test
.helper 
import assertRegexpMatches
 
  28 class TestUnicodeLiterals(unittest
.TestCase
): 
  29     def test_all_files(self
): 
  30         for dirpath
, dirnames
, filenames 
in os
.walk(rootDir
): 
  31             for ignore_dir 
in IGNORED_DIRS
: 
  32                 if ignore_dir 
in dirnames
: 
  33                     # If we remove the directory from dirnames os.walk won't 
  35                     dirnames
.remove(ignore_dir
) 
  36             for basename 
in filenames
: 
  37                 if not basename
.endswith('.py'): 
  39                 if basename 
in IGNORED_FILES
: 
  42                 fn 
= os
.path
.join(dirpath
, basename
) 
  43                 with io
.open(fn
, encoding
='utf-8') as inf
: 
  46                 if "'" not in code 
and '"' not in code
: 
  51                     r
'(?:(?:#.*?|\s*)\n)*from __future__ import (?:[a-z_]+,\s*)*unicode_literals', 
  52                     'unicode_literals import  missing in %s' % fn
) 
  54                 m 
= re
.search(r
'(?<=\s)u[\'"](?!\)|,|$)', code) 
  58                         'u present in %s, around %s' % ( 
  59                             fn, code[m.start() - 10:m.end() + 10])) 
  62 if __name__ == '__main__':