diff options
author | maheshgudi | 2018-07-04 16:34:56 +0530 |
---|---|---|
committer | maheshgudi | 2018-07-12 18:27:27 +0530 |
commit | 99f0c944fafec51b9327fe5dea01096842788e03 (patch) | |
tree | ec3586b1fca3f48c97bb24b131451677bea7a856 /yaksh/evaluator_tests | |
parent | a850749942d163f9aedb19a1d19c4b8d7016745d (diff) | |
download | online_test-99f0c944fafec51b9327fe5dea01096842788e03.tar.gz online_test-99f0c944fafec51b9327fe5dea01096842788e03.tar.bz2 online_test-99f0c944fafec51b9327fe5dea01096842788e03.zip |
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
Diffstat (limited to 'yaksh/evaluator_tests')
-rw-r--r-- | yaksh/evaluator_tests/test_c_cpp_evaluation.py | 29 | ||||
-rw-r--r-- | yaksh/evaluator_tests/test_java_evaluation.py | 23 |
2 files changed, 29 insertions, 23 deletions
diff --git a/yaksh/evaluator_tests/test_c_cpp_evaluation.py b/yaksh/evaluator_tests/test_c_cpp_evaluation.py index 5b49671..17f7c82 100644 --- a/yaksh/evaluator_tests/test_c_cpp_evaluation.py +++ b/yaksh/evaluator_tests/test_c_cpp_evaluation.py @@ -100,12 +100,12 @@ 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 +122,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,14 +274,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): def setUp(self): @@ -432,10 +432,13 @@ 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 +639,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 |