yeukhon / testcapture

(INCUBATOR! CODE ARE MESSY) A simple Python program that allows statements and expressions within a test function body to be recorded and replay at later time by using Python's AST module to rewrite the test code.
0 stars 0 forks source link

Write the ast nodes into a source file #12

Open yeukhon opened 10 years ago

yeukhon commented 10 years ago

Idea is getting the modified ast nodes into an actual source file so we can just run from there.

yeukhon commented 10 years ago

We know unparser.Unparser(new_nodes, sys.stdout) will unparse ast nodes into source code and we could totally pipe it into a file. Is there a different way?

yeukhon commented 10 years ago

Oh and using unparser.Unparser(new_nodes, sys.stdout) we would need to add two things: adding Monitor dictionary and monitor_on function into the modified ast nodes.

yeukhon commented 10 years ago

Well we don't exactly HAVE to do that, but we will have to create a 2nd module which has the dictionary and the function, and import the modified module from the new source code. The pro of this approach is if we have more functions, we can easily do it without touching ast. The cons are another file and another import.