diff options
author | Timotej Lazar <timotej.lazar@araneo.org> | 2015-09-11 11:23:24 +0200 |
---|---|---|
committer | Timotej Lazar <timotej.lazar@araneo.org> | 2015-09-11 11:23:24 +0200 |
commit | f42daa8b31b5772f60d8d8656ad2a5d5d6fd6f67 (patch) | |
tree | 1b2d75e99eb6189dc72de2b60836b41afc5fd354 /python | |
parent | 046463bcebe08c6cbe3504d676c0bf27f8695482 (diff) |
Replace session parameter with Python run function
In hint and test functions, we don't need any session data except the
Python runner.
Diffstat (limited to 'python')
-rw-r--r-- | python/common.py | 2 | ||||
-rw-r--r-- | python/problems/introduction/fahrenheit_to_celsius/common.py | 6 |
2 files changed, 4 insertions, 4 deletions
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']): |