Esempio n. 1
0
 def testWriteBlock(self):
   writer = util.Writer()
   mod_block = block.ModuleBlock(None, '__main__', '<test>', '',
                                 imputil.FutureFeatures())
   writer.write_block(mod_block, 'BODY')
   output = writer.getvalue()
   dispatch = 'switch πF.State() {\n\tcase 0:\n\tdefault: panic'
   self.assertIn(dispatch, output)
Esempio n. 2
0
def _ParseAndVisit(source):
    mod = pythonparser.parse(source)
    _, future_features = imputil.parse_future_features(mod)
    importer = imputil.Importer(None, 'foo', 'foo.py', False)
    b = block.ModuleBlock(importer, '__main__', '<test>', source,
                          future_features)
    visitor = stmt.StatementVisitor(b)
    visitor.visit(mod)
    return visitor
Esempio n. 3
0
def _MakeModuleBlock():
    return block.ModuleBlock(None, '__main__', '<test>', '',
                             imputil.FutureFeatures())
Esempio n. 4
0
def _MakeModuleBlock():
  importer = imputil.Importer(None, '__main__', '/tmp/foo.py', False)
  return block.ModuleBlock(importer, '__main__', '<test>', '',
                           imputil.FutureFeatures())