1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
import glob
import os
import unittest
import gast
class SelfTestCase(unittest.TestCase):
def setUp(self):
self.srcs = glob.glob(os.path.join(gast.__path__[0], '*.py'))
def testParse(self):
for src_py in self.srcs:
with open(src_py) as f:
content = f.read()
gast.parse(content)
def testCompile(self):
for src_py in self.srcs:
with open(src_py) as f:
content = f.read()
gnode = gast.parse(content)
compile(gast.gast_to_ast(gnode), src_py, 'exec')
def test_unparse(self):
for src_py in self.srcs:
with open(src_py) as f:
content = f.read()
gnode = gast.parse(content)
gast.unparse(gnode)
if __name__ == '__main__':
unittest.main()
|