diff options
Diffstat (limited to 'runner/test.py')
-rw-r--r-- | runner/test.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/runner/test.py b/runner/test.py new file mode 100644 index 0000000..08f0441 --- /dev/null +++ b/runner/test.py @@ -0,0 +1,21 @@ +import sys +from io import StringIO + +def execute(snippet): + old_stdout = sys.stdout + redirected_output = sys.stdout = StringIO() + try: + exec(snippet) + except: + raise + finally: + sys.stdout = old_stdout + + return redirected_output.getvalue() + + +code = """ +i = [0,1,2] +for j in i: + print(j) +""" |