From 0520bf284f9b34782fa90b433d714c887049f339 Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Thu, 17 Mar 2016 16:42:33 +0530 Subject: - Add test cases for multiple python evaluators - Change name from python_standard_evaluator to python_assertion_evaluator --- yaksh/python_stdout_evaluator.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'yaksh/python_stdout_evaluator.py') 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, '', 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 -- cgit