diff options
author | King | 2016-07-28 17:39:44 +0530 |
---|---|---|
committer | GitHub | 2016-07-28 17:39:44 +0530 |
commit | 2b03aeb36fa333ea1644a248c742cf0c1df12a5f (patch) | |
tree | 4c753ba9a1fbccf3e06d1ed1d998137c88a73b88 /yaksh/python_stdout_evaluator.py | |
parent | 344e1e804cee214c0d0f5c41ca16d871e786d4c3 (diff) | |
parent | 83bee9d89e163e98504c8aa210ce60200bd1cd1d (diff) | |
download | online_test-2b03aeb36fa333ea1644a248c742cf0c1df12a5f.tar.gz online_test-2b03aeb36fa333ea1644a248c742cf0c1df12a5f.tar.bz2 online_test-2b03aeb36fa333ea1644a248c742cf0c1df12a5f.zip |
Merge pull request #113 from adityacp/file_based_questions
File based questions
Diffstat (limited to 'yaksh/python_stdout_evaluator.py')
-rw-r--r-- | yaksh/python_stdout_evaluator.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/yaksh/python_stdout_evaluator.py b/yaksh/python_stdout_evaluator.py index 6606581..8f69b24 100644 --- a/yaksh/python_stdout_evaluator.py +++ b/yaksh/python_stdout_evaluator.py @@ -8,6 +8,7 @@ from contextlib import contextmanager # local imports from code_evaluator import CodeEvaluator +from file_utils import copy_files, delete_files @contextmanager @@ -25,7 +26,16 @@ def redirect_stdout(): class PythonStdoutEvaluator(CodeEvaluator): """Tests the Python code obtained from Code Server""" - def compile_code(self, user_answer, expected_output): + def teardown(self): + super(PythonStdoutEvaluator, self).teardown() + # Delete the created file. + if self.files: + delete_files(self.files) + + def compile_code(self, user_answer, file_paths, expected_output): + self.files = [] + if file_paths: + self.files = copy_files(file_paths) if hasattr(self, 'output_value'): return None else: @@ -36,9 +46,8 @@ class PythonStdoutEvaluator(CodeEvaluator): self.output_value = output_buffer.getvalue() return self.output_value - def check_code(self, user_answer, expected_output): + def check_code(self, user_answer, file_paths, expected_output): success = False - tb = None if expected_output in user_answer: success = False @@ -52,7 +61,5 @@ class PythonStdoutEvaluator(CodeEvaluator): else: success = False err = "Incorrect Answer" - del tb return success, err - |