diff options
author | ankitjavalkar | 2016-04-21 17:31:09 +0530 |
---|---|---|
committer | ankitjavalkar | 2016-05-05 19:16:26 +0530 |
commit | 5684b1b19fcb383f494f0bfc04ad1bb760abce74 (patch) | |
tree | 6d40b0cb151b9ab9d40d6c6479617f2eee5ed04b /yaksh/python_assertion_evaluator.py | |
parent | 2c7f278382f4fe8071508b0a880aae34f8edfd5e (diff) | |
download | online_test-5684b1b19fcb383f494f0bfc04ad1bb760abce74.tar.gz online_test-5684b1b19fcb383f494f0bfc04ad1bb760abce74.tar.bz2 online_test-5684b1b19fcb383f494f0bfc04ad1bb760abce74.zip |
Post review improvements:
- compiled_output is set during setup
- python exec context renamed
- _compile_command deprecated
Diffstat (limited to 'yaksh/python_assertion_evaluator.py')
-rw-r--r-- | yaksh/python_assertion_evaluator.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/yaksh/python_assertion_evaluator.py b/yaksh/python_assertion_evaluator.py index c6661d1..82b5912 100644 --- a/yaksh/python_assertion_evaluator.py +++ b/yaksh/python_assertion_evaluator.py @@ -12,14 +12,18 @@ from code_evaluator import CodeEvaluator, TimeoutException class PythonAssertionEvaluator(CodeEvaluator): """Tests the Python code obtained from Code Server""" + def setup(self): + super(PythonAssertionEvaluator, self).setup() + self.exec_scope = None + def compile_code(self, user_answer, test_case): - if hasattr(self, 'g'): + if self.exec_scope: return None else: submitted = compile(user_answer, '<string>', mode='exec') - self.g = {} - exec submitted in self.g - return self.g + self.exec_scope = {} + exec submitted in self.exec_scope + return self.exec_scope # def check_code(self, test, user_answer, ref_code_path): # def check_code(self, user_answer, test_case_data): #@@@v2 @@ -31,7 +35,7 @@ class PythonAssertionEvaluator(CodeEvaluator): # g = {} # exec submitted in g _tests = compile(test_case, '<string>', mode='exec') - exec _tests in self.g + exec _tests in self.exec_scope except AssertionError: type, value, tb = sys.exc_info() info = traceback.extract_tb(tb) |