summaryrefslogtreecommitdiff
path: root/python/problems
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@araneo.org>2015-09-03 18:25:25 +0200
committerTimotej Lazar <timotej.lazar@araneo.org>2015-09-03 18:25:25 +0200
commit20d9c7e226ec7e7931a209cde597fbe56b3b8e64 (patch)
tree98a5be20699dca410cf5b8da834a1b42874b7585 /python/problems
parentcb6109117d7ab4da0a8b1b996435e313787a7cde (diff)
Pass the session object to test and hint functions
Diffstat (limited to 'python/problems')
-rw-r--r--python/problems/introduction/fahrenheit_to_celsius/common.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/python/problems/introduction/fahrenheit_to_celsius/common.py b/python/problems/introduction/fahrenheit_to_celsius/common.py
index 53a17f8..1555cf7 100644
--- a/python/problems/introduction/fahrenheit_to_celsius/common.py
+++ b/python/problems/introduction/fahrenheit_to_celsius/common.py
@@ -11,10 +11,9 @@ f = float(input("Temperatura [F]: "))
print("Temperatura je", c, "C")
'''
-from python.engine import run
from python.util import has_token_sequence
-def test(code):
+def test(session, code):
# List of inputs: (expression to eval, stdin).
test_in = [
(None, '0\n'),
@@ -26,7 +25,7 @@ def test(code):
]
# List of outputs: (expression result, stdout, stderr, exception).
- answers = run(code=code, inputs=test_in, timeout=1.0)
+ answers = session.get_python().run(code=code, inputs=test_in, timeout=1.0)
outputs = [ans[1] for ans in answers]
n_correct = 0
@@ -35,7 +34,7 @@ def test(code):
n_correct += 1
return n_correct, len(test_in)
-def hint(code):
+def hint(session, code):
if not code:
return [{'id': 'plan'}]
if not has_token_sequence(code, ['input']):