summaryrefslogtreecommitdiff
path: root/yaksh/python_stdout_evaluator.py
diff options
context:
space:
mode:
Diffstat (limited to 'yaksh/python_stdout_evaluator.py')
-rw-r--r--yaksh/python_stdout_evaluator.py17
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
-