import unittest import os import tokenize import ast ALL_NAMES = [ ['/home/haypo/prog/python/master/Lib/test/test_pprint.py'], ['/home/haypo/prog/python/master/Lib/test/test_wsgiref.py'], ['/home/haypo/prog/python/master/Lib/test/test_yield_from.py'], ['/home/haypo/prog/python/master/Lib/test/coding20731.py'], ] NEXT = iter(ALL_NAMES).__next__ class DirectoryTestCase(unittest.TestCase): def test_files(self): names = NEXT() for filename in names: with tokenize.open(filename) as pyfile: source = pyfile.read() compile(source, "filename", "exec", ast.PyCF_ONLY_AST) if __name__ == '__main__': unittest.main()