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__))))
14 rootDir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
17 'setup.py', # http://bugs.python.org/issue13943
23 from test.helper import assertRegexpMatches
26 class TestUnicodeLiterals(unittest.TestCase):
27 def test_all_files(self):
28 for dirpath, _, filenames in os.walk(rootDir):
29 for basename in filenames:
30 if not basename.endswith('.py'):
32 if basename in IGNORED_FILES:
35 fn = os.path.join(dirpath, basename)
36 with io.open(fn, encoding='utf-8') as inf:
39 if "'" not in code and '"' not in code:
44 r'(?:(?:#.*?|\s*)\n)*from __future__ import (?:[a-z_]+,\s*)*unicode_literals',
45 'unicode_literals import missing in %s' % fn)
47 m = re.search(r'(?<=\s)u[\'"](?!\)|,|$)', code)
51 'u present in %s, around %s' % (
52 fn, code[m.start() - 10:m.end() + 10]))
55 if __name__ == '__main__':