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