make the patched compile() work with AST
--HG-- branch : trunk
This commit is contained in:
@@ -191,6 +191,15 @@ class TestSourceParsingAndCompiling:
|
||||
assert len(source) == 9
|
||||
assert source.getstatementrange(5) == (0, 9)
|
||||
|
||||
def test_compile_to_ast(self):
|
||||
if sys.version_info < (2, 5):
|
||||
py.test.skip("requires Python 2.5")
|
||||
import _ast
|
||||
source = Source("x = 4")
|
||||
mod = source.compile(flag=_ast.PyCF_ONLY_AST)
|
||||
assert isinstance(mod, _ast.Module)
|
||||
compile(mod, "<filename>", "exec")
|
||||
|
||||
def test_compile_and_getsource(self):
|
||||
co = self.source.compile()
|
||||
py.builtin.exec_(co, globals())
|
||||
|
||||
Reference in New Issue
Block a user