diff options
author | Prabhu Ramachandran | 2016-09-29 12:33:08 +0530 |
---|---|---|
committer | GitHub | 2016-09-29 12:33:08 +0530 |
commit | 8b410d3764b8f0e5c7a14e292a5583ef93c4257e (patch) | |
tree | 18b9ca9a9dd202c61a83244337859fb4ba8b4e6c /yaksh/stdio_evaluator.py | |
parent | 8e4ead8ab4caa9366e5357840e1912cbfb8cdb85 (diff) | |
parent | 086620367c481009c9caed68660865ca127a9520 (diff) | |
download | online_test-8b410d3764b8f0e5c7a14e292a5583ef93c4257e.tar.gz online_test-8b410d3764b8f0e5c7a14e292a5583ef93c4257e.tar.bz2 online_test-8b410d3764b8f0e5c7a14e292a5583ef93c4257e.zip |
Merge pull request #141 from maheshgudi/refactor_stdio
Refactor stdio
Diffstat (limited to 'yaksh/stdio_evaluator.py')
-rw-r--r-- | yaksh/stdio_evaluator.py | 20 |
1 files changed, 16 insertions, 4 deletions
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 |