diff options
author | prathamesh | 2016-10-04 17:22:20 +0530 |
---|---|---|
committer | prathamesh | 2016-10-04 17:22:20 +0530 |
commit | 9c14e2b2026074234d9c977ca17b0c96b0789f6b (patch) | |
tree | 8b6c8e2438563e56631c2adf986e7cb16c33afb4 /yaksh/python_assertion_evaluator.py | |
parent | c5ae3d4589a71c3f3b9f622c7b67a04277269cde (diff) | |
parent | 91dd42214ba5ad88c5158b50a7746caa3841a883 (diff) | |
download | online_test-9c14e2b2026074234d9c977ca17b0c96b0789f6b.tar.gz online_test-9c14e2b2026074234d9c977ca17b0c96b0789f6b.tar.bz2 online_test-9c14e2b2026074234d9c977ca17b0c96b0789f6b.zip |
Merge branch 'master' of https://github.com/FOSSEE/online_test into edit_questionpaper
Resolved
Conflicts:
yaksh/views.py
Diffstat (limited to 'yaksh/python_assertion_evaluator.py')
-rw-r--r-- | yaksh/python_assertion_evaluator.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/yaksh/python_assertion_evaluator.py b/yaksh/python_assertion_evaluator.py index 1b66fd2..dd1c041 100644 --- a/yaksh/python_assertion_evaluator.py +++ b/yaksh/python_assertion_evaluator.py @@ -1,13 +1,14 @@ #!/usr/bin/env python +from __future__ import unicode_literals import sys import traceback import os from os.path import join import importlib -# local imports -from code_evaluator import CodeEvaluator, TimeoutException -from file_utils import copy_files, delete_files +# Local imports +from .code_evaluator import CodeEvaluator, TimeoutException +from .file_utils import copy_files, delete_files class PythonAssertionEvaluator(CodeEvaluator): @@ -18,10 +19,10 @@ class PythonAssertionEvaluator(CodeEvaluator): self.exec_scope = None def teardown(self): - super(PythonAssertionEvaluator, self).teardown() # Delete the created file. if self.files: delete_files(self.files) + super(PythonAssertionEvaluator, self).teardown() def compile_code(self, user_answer, file_paths, test_case): self.files = [] @@ -32,7 +33,7 @@ class PythonAssertionEvaluator(CodeEvaluator): else: submitted = compile(user_answer, '<string>', mode='exec') self.exec_scope = {} - exec submitted in self.exec_scope + exec(submitted, self.exec_scope) return self.exec_scope def check_code(self, user_answer, file_paths, test_case): @@ -40,7 +41,7 @@ class PythonAssertionEvaluator(CodeEvaluator): try: tb = None _tests = compile(test_case, '<string>', mode='exec') - exec _tests in self.exec_scope + exec(_tests, self.exec_scope) except AssertionError: type, value, tb = sys.exc_info() info = traceback.extract_tb(tb) |