From 99f0c944fafec51b9327fe5dea01096842788e03 Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Wed, 4 Jul 2018 16:34:56 +0530 Subject: Raise appropriate exceptions for C and Java language to the Grader - Raise AssertionError,CompilationError and TestCaseError for assertion, user answer compilation and testcase compilation errors respectively. - Add test case for C/C++ and Java --- yaksh/evaluator_tests/test_java_evaluation.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'yaksh/evaluator_tests/test_java_evaluation.py') diff --git a/yaksh/evaluator_tests/test_java_evaluation.py b/yaksh/evaluator_tests/test_java_evaluation.py index ab86dec..eb09f2f 100644 --- a/yaksh/evaluator_tests/test_java_evaluation.py +++ b/yaksh/evaluator_tests/test_java_evaluation.py @@ -113,13 +113,12 @@ class JavaAssertionEvaluationTestCases(EvaluatorBaseTest): # When grader = Grader(self.in_dir) result = grader.evaluate(kwargs) + errors = result.get('error') # Then self.assertFalse(result.get('success')) - lines_of_error = len(result.get('error')[0].splitlines()) - self.assertFalse(result.get('success')) - self.assert_correct_output("Incorrect", result.get('error')) - self.assertTrue(lines_of_error > 1) + for error in errors: + self.assertEqual(error.get('exception'), 'AssertionError') def test_error(self): # Given @@ -136,10 +135,11 @@ class JavaAssertionEvaluationTestCases(EvaluatorBaseTest): # When grader = Grader(self.in_dir) result = grader.evaluate(kwargs) - + errors = result.get('error') # Then self.assertFalse(result.get("success")) - self.assert_correct_output("Error", result.get("error")) + for error in errors: + self.assertEqual(error.get('exception'), 'CompilationError') def test_infinite_loop(self): # Given @@ -290,13 +290,12 @@ class JavaAssertionEvaluationTestCases(EvaluatorBaseTest): # When grader = Grader(self.in_dir) result = grader.evaluate(kwargs) + errors = result.get('error') # Then - err = result.get('error')[0] - lines_of_error = len(err.splitlines()) self.assertFalse(result.get('success')) - self.assertTrue(lines_of_error > 1) - self.assertIn("Test case Error", err) + for error in errors: + self.assertEqual(error.get('exception'), 'TestCaseError') class JavaStdIOEvaluationTestCases(EvaluatorBaseTest): @@ -432,10 +431,12 @@ class JavaStdIOEvaluationTestCases(EvaluatorBaseTest): # When grader = Grader(self.in_dir) result = grader.evaluate(kwargs) + errors = result.get('error') # Then self.assertFalse(result.get("success")) - self.assertTrue("Compilation Error" in '\n'.join(result.get("error"))) + for error in errors: + self.assertEqual(error.get('exception'), 'CompilationError') def test_infinite_loop(self): # Given -- cgit