summaryrefslogtreecommitdiff
path: root/yaksh/python_stdout_evaluator.py
diff options
context:
space:
mode:
authorankitjavalkar2016-03-17 16:42:33 +0530
committerankitjavalkar2016-05-05 19:00:33 +0530
commit0520bf284f9b34782fa90b433d714c887049f339 (patch)
treeff1d81f59ea849740bd37ca70a11eaa821187fbc /yaksh/python_stdout_evaluator.py
parent195aead9b0fab0d8cdb86a9fc884ac3edca5db84 (diff)
downloadonline_test-0520bf284f9b34782fa90b433d714c887049f339.tar.gz
online_test-0520bf284f9b34782fa90b433d714c887049f339.tar.bz2
online_test-0520bf284f9b34782fa90b433d714c887049f339.zip
- Add test cases for multiple python evaluators
- Change name from python_standard_evaluator to python_assertion_evaluator
Diffstat (limited to 'yaksh/python_stdout_evaluator.py')
-rw-r--r--yaksh/python_stdout_evaluator.py15
1 files changed, 5 insertions, 10 deletions
diff --git a/yaksh/python_stdout_evaluator.py b/yaksh/python_stdout_evaluator.py
index 28c3372..8f3eb65 100644
--- a/yaksh/python_stdout_evaluator.py
+++ b/yaksh/python_stdout_evaluator.py
@@ -25,29 +25,24 @@ def redirect_stdout():
class PythonStdoutEvaluator(CodeEvaluator):
"""Tests the Python code obtained from Code Server"""
- def check_code(self, user_answer, test_cases):
+ def check_code(self, user_answer, test_case_data):
success = False
tb = None
- expected_output = test_cases[0]
+ expected_output = test_case_data[0]
submitted = compile(user_answer, '<string>', mode='exec')
with redirect_stdout() as output_buffer:
g = {}
exec submitted in g
raw_output_value = output_buffer.getvalue()
output_value = raw_output_value.encode('string_escape').strip()
- if output_value == str(test_code):
+ if output_value == expected_output:
success = True
- err = 'Correct answer'
+ err = "Correct answer"
+
else:
success = False
err = "Incorrect Answer"
del tb
return success, err
-
- # def unpack_test_case_data(self, test_case_data):
- # for t in test_case_data:
- # test_case = t.get('output')
-
- # return test_case