From 195aead9b0fab0d8cdb86a9fc884ac3edca5db84 Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Wed, 16 Mar 2016 10:57:07 +0530 Subject: - Connect test case type models to backend code server - Support for Stdout test case and Standard assertion test case - Add MCQ Test case and support for validations - Remove tester dir --- yaksh/python_code_evaluator.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'yaksh/python_code_evaluator.py') diff --git a/yaksh/python_code_evaluator.py b/yaksh/python_code_evaluator.py index 5722b2d..a131a0e 100644 --- a/yaksh/python_code_evaluator.py +++ b/yaksh/python_code_evaluator.py @@ -12,17 +12,18 @@ from code_evaluator import CodeEvaluator, TimeoutException class PythonCodeEvaluator(CodeEvaluator): """Tests the Python code obtained from Code Server""" - def check_code(self, test, user_answer, ref_code_path): + # def check_code(self, test, user_answer, ref_code_path): + def check_code(self, user_answer, test_cases): success = False try: tb = None - test_code = test submitted = compile(user_answer, '', mode='exec') g = {} exec submitted in g - _tests = compile(test_code, '', mode='exec') - exec _tests in g + for test_code in test_cases: + _tests = compile(test_code, '', mode='exec') + exec _tests in g except AssertionError: type, value, tb = sys.exc_info() info = traceback.extract_tb(tb) @@ -40,6 +41,14 @@ class PythonCodeEvaluator(CodeEvaluator): del tb return success, err + # def unpack_test_case_data(self, test_case_data): + # test_cases = [] + # for t in test_case_data: + # test_case = t.get('test_case') + # test_cases.append(test_case) + + # return test_cases + # def check_code(self): # success = False -- cgit