import sys, cStringIO import parser import ast def getast(source): st = parser.suite(source) prev_debug = ast.debug try: ast.debug = 1 a = ast.st2ast(st) finally: ast.debug = prev_debug return a def test_simple(): getast("print >> 7, 3 or 4, 5,; 6")