From f42daa8b31b5772f60d8d8656ad2a5d5d6fd6f67 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Fri, 11 Sep 2015 11:23:24 +0200 Subject: Replace session parameter with Python run function In hint and test functions, we don't need any session data except the Python runner. --- python/common.py | 2 +- python/problems/introduction/fahrenheit_to_celsius/common.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'python') diff --git a/python/common.py b/python/common.py index 39c323f..5ce2eb3 100644 --- a/python/common.py +++ b/python/common.py @@ -9,7 +9,7 @@ hint_type = { 'syntax_error': Hint('syntax_error'), } -def hint(program): +def hint(python, program): # Check program for syntax errors. try: tree = ast.parse(program, filename='user') diff --git a/python/problems/introduction/fahrenheit_to_celsius/common.py b/python/problems/introduction/fahrenheit_to_celsius/common.py index 5c8e0cd..34f2832 100644 --- a/python/problems/introduction/fahrenheit_to_celsius/common.py +++ b/python/problems/introduction/fahrenheit_to_celsius/common.py @@ -19,7 +19,7 @@ hint_type = { 'no_input_call': Hint('no_input_call'), } -def test(session, code): +def test(python, code): # List of inputs: (expression to eval, stdin). test_in = [ (None, '0\n'), @@ -31,7 +31,7 @@ def test(session, code): ] # List of outputs: (expression result, stdout, stderr, exception). - answers = session.get_python().run(code=code, inputs=test_in, timeout=1.0) + answers = python(code=code, inputs=test_in, timeout=1.0) outputs = [ans[1] for ans in answers] n_correct = 0 @@ -40,7 +40,7 @@ def test(session, code): n_correct += 1 return n_correct, len(test_in) -def hint(session, code): +def hint(python, code): if not code: return [{'id': 'plan'}] if not has_token_sequence(code, ['input']): -- cgit v1.2.1