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_assertion_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_assertion_evaluator.py')
-rw-r--r-- | yaksh/python_assertion_evaluator.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/yaksh/python_assertion_evaluator.py b/yaksh/python_assertion_evaluator.py index bf6a4be..04a4e69 100644 --- a/yaksh/python_assertion_evaluator.py +++ b/yaksh/python_assertion_evaluator.py @@ -7,6 +7,7 @@ import importlib # local imports from code_evaluator import CodeEvaluator, TimeoutException +from file_utils import copy_files, delete_files class PythonAssertionEvaluator(CodeEvaluator): @@ -16,7 +17,16 @@ class PythonAssertionEvaluator(CodeEvaluator): super(PythonAssertionEvaluator, self).setup() self.exec_scope = None - def compile_code(self, user_answer, test_case): + def teardown(self): + super(PythonAssertionEvaluator, self).teardown() + # Delete the created file. + if self.files: + delete_files(self.files) + + def compile_code(self, user_answer, file_paths, test_case): + self.files = [] + if file_paths: + self.files = copy_files(file_paths) if self.exec_scope: return None else: @@ -25,7 +35,7 @@ class PythonAssertionEvaluator(CodeEvaluator): exec submitted in self.exec_scope return self.exec_scope - def check_code(self, user_answer, test_case): + def check_code(self, user_answer, file_paths, test_case): success = False try: tb = None @@ -42,6 +52,5 @@ class PythonAssertionEvaluator(CodeEvaluator): else: success = True err = 'Correct answer' - del tb return success, err |