From 2cb22a95912e6fe6bf97046de654207e4f265d8c Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Fri, 18 Nov 2016 16:30:36 +0530 Subject: fixed test cases and added timeout exception in python assertion --- yaksh/evaluator_tests/test_python_evaluation.py | 13 +++++-------- yaksh/python_assertion_evaluator.py | 2 ++ 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'yaksh') diff --git a/yaksh/evaluator_tests/test_python_evaluation.py b/yaksh/evaluator_tests/test_python_evaluation.py index 9796fa2..acf5d0a 100644 --- a/yaksh/evaluator_tests/test_python_evaluation.py +++ b/yaksh/evaluator_tests/test_python_evaluation.py @@ -200,7 +200,7 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase): # Then self.assertFalse(result.get("success")) - self.assertEqual(3, len(err)) + self.assertEqual(9, len(err)) for msg in name_error_msg: self.assertIn(msg, result.get("error")) @@ -254,7 +254,7 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase): # Then self.assertFalse(result.get("success")) - self.assertEqual(3, len(err)) + self.assertEqual(9, len(err)) for msg in type_error_msg: self.assertIn(msg, result.get("error")) @@ -284,7 +284,7 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase): # Then self.assertFalse(result.get("success")) - self.assertEqual(4, len(err)) + self.assertEqual(9, len(err)) for msg in value_error_msg: self.assertIn(msg, result.get("error")) @@ -341,7 +341,7 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase): # Then self.assertFalse(result.get("success")) - self.assertEqual(5, len(err)) + self.assertEqual(6, len(err)) for msg in syntax_error_msg: self.assertIn(msg, result.get("error")) @@ -360,9 +360,6 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase): ] name_error_msg = ["Traceback", "call", - "File", - "line", - "", "NameError", "name 'S' is not defined" ] @@ -379,7 +376,7 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase): # Then self.assertFalse(result.get("success")) - self.assertEqual(3, len(err)) + self.assertEqual(7, len(err)) for msg in name_error_msg: self.assertIn(msg, result.get("error")) diff --git a/yaksh/python_assertion_evaluator.py b/yaksh/python_assertion_evaluator.py index ba1890f..986dbf2 100644 --- a/yaksh/python_assertion_evaluator.py +++ b/yaksh/python_assertion_evaluator.py @@ -73,6 +73,8 @@ class PythonAssertionEvaluator(CodeEvaluator): type.__name__, str(value), text ) + except TimeoutException: + raise except Exception: msg = traceback.format_exc(limit=0) err = "Error in Test case: {0}".format(msg) -- cgit