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)
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
def _MakeModuleBlock(): return block.ModuleBlock(None, '__main__', '<test>', '', imputil.FutureFeatures())
def _MakeModuleBlock(): importer = imputil.Importer(None, '__main__', '/tmp/foo.py', False) return block.ModuleBlock(importer, '__main__', '<test>', '', imputil.FutureFeatures())