def test_parse(self): for i, test in enumerate(self.tests): with self.subTest(test=i): result = parse(test.input) expected = ast.fix_missing_locations(test.output) self.assertEqual(ast.dump(result, include_attributes=True), ast.dump(expected, include_attributes=True))
def main(): """Read source from stdin, parse and export the AST as JSON""" parser = create_parser() args = parser.parse_args() if args.version: print("{} version {}".format(__prog_name__, __version__)) return source = "".join(fileinput.input(args.input)) tree = parse(source) json = export_json(tree, args.pretty) print(json)