diff options
author | King | 2018-07-12 14:00:59 -0700 |
---|---|---|
committer | GitHub | 2018-07-12 14:00:59 -0700 |
commit | 661c9d82bb680e745cc6b498131a0793b954c436 (patch) | |
tree | 9982e226f9bf81aaab98d752db3a8aba3de0c631 /yaksh/evaluator_tests | |
parent | f61742f04f417cfb60576f9904afd0dc5c537b3c (diff) | |
parent | 714eeb188c67a6b61dfd132f0869e7679d91c8bf (diff) | |
download | online_test-661c9d82bb680e745cc6b498131a0793b954c436.tar.gz online_test-661c9d82bb680e745cc6b498131a0793b954c436.tar.bz2 online_test-661c9d82bb680e745cc6b498131a0793b954c436.zip |
Merge pull request #491 from maheshgudi/catch_compilation_error
Raise appropriate exceptions for C and Java language to the Grader
Diffstat (limited to 'yaksh/evaluator_tests')
-rw-r--r-- | yaksh/evaluator_tests/test_c_cpp_evaluation.py | 26 | ||||
-rw-r--r-- | yaksh/evaluator_tests/test_java_evaluation.py | 23 |
2 files changed, 27 insertions, 22 deletions
diff --git a/yaksh/evaluator_tests/test_c_cpp_evaluation.py b/yaksh/evaluator_tests/test_c_cpp_evaluation.py index 5b49671..14ed808 100644 --- a/yaksh/evaluator_tests/test_c_cpp_evaluation.py +++ b/yaksh/evaluator_tests/test_c_cpp_evaluation.py @@ -100,12 +100,11 @@ class CAssertionEvaluationTestCases(EvaluatorBaseTest): # When grader = Grader(self.in_dir) result = grader.evaluate(kwargs) - + errors = result.get('error') # Then - 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['exception'], 'AssertionError') def test_compilation_error(self): # Given @@ -122,10 +121,12 @@ class CAssertionEvaluationTestCases(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("Compilation Error", result.get("error")) + for error in errors: + self.assertEqual(error['exception'], 'CompilationError') def test_infinite_loop(self): # Given @@ -272,13 +273,12 @@ class CAssertionEvaluationTestCases(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['exception'], 'TestCaseError') class CppStdIOEvaluationTestCases(EvaluatorBaseTest): @@ -432,10 +432,12 @@ class CppStdIOEvaluationTestCases(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("Compilation Error", result.get("error")) + for error in errors: + self.assertEqual(error['exception'], 'CompilationError') def test_infinite_loop(self): # Given @@ -636,10 +638,12 @@ class CppStdIOEvaluationTestCases(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("Compilation Error", result.get("error")) + for error in errors: + self.assertEqual(error['exception'], 'CompilationError') def test_cpp_infinite_loop(self): # Given 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 |