Example #1
0
 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))
Example #2
0
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)
Example #3
0
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)
Example #4
0
 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))