From ed46c4a2cf6bbf41f50faafc785f001e3d10d195 Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Mon, 26 Sep 2016 18:15:04 +0530 Subject: refactored stdio_evaluator --- yaksh/stdio_evaluator.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'yaksh/stdio_evaluator.py') diff --git a/yaksh/stdio_evaluator.py b/yaksh/stdio_evaluator.py index 4f5cfaf..efb2ae5 100644 --- a/yaksh/stdio_evaluator.py +++ b/yaksh/stdio_evaluator.py @@ -1,6 +1,18 @@ -class Evaluator(object): +# Local imports +from code_evaluator import CodeEvaluator - def evaluate(self, user_answer, proc, expected_input, expected_output): + +class StdIOEvaluator(CodeEvaluator): + + def setup(self): + super(StdIOEvaluator, self).setup() + pass + + def teardown(self): + super(StdIOEvaluator, self).teardown() + pass + + def evaluate_stdio(self, user_answer, proc, expected_input, expected_output): success = False ip = expected_input.replace(",", " ") user_output, output_err = proc.communicate(input='{0}\n'.format(ip)) @@ -13,9 +25,9 @@ class Evaluator(object): format(expected_input, repr(expected_output)) if output_err == '': if user_output == expected_output: - success, err = True, "Correct Answer" + success, err = True, "Correct answer" else: - err = " Incorrect Answer\n" + error_msg +\ + err = " Incorrect answer\n" + error_msg +\ "\n Your output is {0}".format(repr(user_output)) else: err = "Error:"+"\n"+output_err -- cgit