diff options
Diffstat (limited to 'yaksh/evaluator_tests')
-rw-r--r-- | yaksh/evaluator_tests/test_bash_evaluation.py | 3 | ||||
-rw-r--r-- | yaksh/evaluator_tests/test_c_cpp_evaluation.py | 14 | ||||
-rw-r--r-- | yaksh/evaluator_tests/test_java_evaluation.py | 7 | ||||
-rw-r--r-- | yaksh/evaluator_tests/test_python_evaluation.py | 4 | ||||
-rw-r--r-- | yaksh/evaluator_tests/test_python_stdio_evaluator.py | 51 |
5 files changed, 30 insertions, 49 deletions
diff --git a/yaksh/evaluator_tests/test_bash_evaluation.py b/yaksh/evaluator_tests/test_bash_evaluation.py index 8bb8c81..d19ef1c 100644 --- a/yaksh/evaluator_tests/test_bash_evaluation.py +++ b/yaksh/evaluator_tests/test_bash_evaluation.py @@ -242,7 +242,8 @@ class BashStdIOEvaluationTestCases(EvaluatorBaseTest): result = grader.evaluate(kwargs) # Then - self.assert_correct_output("Incorrect", result.get('error')) + result_error = result.get('error')[0].get('error') + self.assert_correct_output("Incorrect", result_error) self.assertFalse(result.get('success')) def test_stdout_only(self): diff --git a/yaksh/evaluator_tests/test_c_cpp_evaluation.py b/yaksh/evaluator_tests/test_c_cpp_evaluation.py index b15f766..46d5593 100644 --- a/yaksh/evaluator_tests/test_c_cpp_evaluation.py +++ b/yaksh/evaluator_tests/test_c_cpp_evaluation.py @@ -350,10 +350,11 @@ class CppStdIOEvaluationTestCases(EvaluatorBaseTest): result = grader.evaluate(kwargs) # Then - lines_of_error = len(result.get('error')[0].splitlines()) + lines_of_error = len(result.get('error')[0].get('error_no')) + result_error = result.get('error')[0].get('error') self.assertFalse(result.get('success')) - self.assert_correct_output("Incorrect", result.get('error')) - self.assertTrue(lines_of_error > 1) + self.assert_correct_output("Incorrect", result_error) + self.assertTrue(lines_of_error > 0) def test_error(self): # Given @@ -558,10 +559,11 @@ class CppStdIOEvaluationTestCases(EvaluatorBaseTest): result = grader.evaluate(kwargs) # Then - lines_of_error = len(result.get('error')[0].splitlines()) + lines_of_error = len(result.get('error')[0].get('error_no')) + result_error = result.get('error')[0].get('error') self.assertFalse(result.get('success')) - self.assert_correct_output("Incorrect", result.get('error')) - self.assertTrue(lines_of_error > 1) + self.assert_correct_output("Incorrect", result_error) + self.assertTrue(lines_of_error > 0) def test_cpp_error(self): # Given diff --git a/yaksh/evaluator_tests/test_java_evaluation.py b/yaksh/evaluator_tests/test_java_evaluation.py index ea558ed..7046aa1 100644 --- a/yaksh/evaluator_tests/test_java_evaluation.py +++ b/yaksh/evaluator_tests/test_java_evaluation.py @@ -349,10 +349,11 @@ class JavaStdIOEvaluationTestCases(EvaluatorBaseTest): result = grader.evaluate(kwargs) # Then - lines_of_error = len(result.get('error')[0].splitlines()) + lines_of_error = len(result.get('error')[0].get('error_no')) + result_error = result.get('error')[0].get('error') self.assertFalse(result.get('success')) - self.assert_correct_output("Incorrect", result.get('error')) - self.assertTrue(lines_of_error > 1) + self.assert_correct_output("Incorrect", result_error) + self.assertTrue(lines_of_error > 0) def test_error(self): # Given diff --git a/yaksh/evaluator_tests/test_python_evaluation.py b/yaksh/evaluator_tests/test_python_evaluation.py index a751c40..8b18c9a 100644 --- a/yaksh/evaluator_tests/test_python_evaluation.py +++ b/yaksh/evaluator_tests/test_python_evaluation.py @@ -613,8 +613,8 @@ class PythonStdIOEvaluationTestCases(EvaluatorBaseTest): # Then self.assertFalse(result.get('success')) self.assert_correct_output( - "ERROR:\nExpected:\n3\nGiven:\n-1\n\nError in line 1 of output.", - result.get('error') + "Incorrect Answer: Line number(s) 1 did not match.", + result.get('error')[0].get('error') ) def test_file_based_answer(self): diff --git a/yaksh/evaluator_tests/test_python_stdio_evaluator.py b/yaksh/evaluator_tests/test_python_stdio_evaluator.py index db5028a..9eab763 100644 --- a/yaksh/evaluator_tests/test_python_stdio_evaluator.py +++ b/yaksh/evaluator_tests/test_python_stdio_evaluator.py @@ -1,62 +1,39 @@ -from textwrap import dedent - -from yaksh.python_stdio_evaluator import compare_outputs - +from yaksh.compare_stdio import CompareOutputs def test_compare_outputs(): exp = "5\n5\n" given = "5\n5\n" - success, msg = compare_outputs(given, exp) + success, msg = CompareOutputs().compare_outputs(given, exp) assert success exp = "5\n5\n" given = "5\n5" - success, msg = compare_outputs(given, exp) + success, msg = CompareOutputs().compare_outputs(given, exp) assert success exp = "5\r5" given = "5\n5" - success, msg = compare_outputs(given, exp) + success, msg = CompareOutputs().compare_outputs(given, exp) assert success exp = " 5 \r 5 " given = " 5 \n 5 " - success, msg = compare_outputs(given, exp) + success, msg = CompareOutputs().compare_outputs(given, exp) assert success exp = "5\n5\n" given = "5 5" - success, msg = compare_outputs(given, exp) + success, msg = CompareOutputs().compare_outputs(given, exp) + error_msg = msg.get('error') assert not success - m = dedent("""\ - ERROR: Got 1 lines in output, we expected 2. - Expected: - 5 - 5 - - Given: - 5 5 - """) - assert m == msg + m = "Incorrect Answer: We had expected 1 number of lines."\ + + " We got 2 number of lines." + assert m == error_msg exp = "5\n5\n" given = "5\n6" - success, msg = compare_outputs(given, exp) + success, msg = CompareOutputs().compare_outputs(given, exp) + error_msg = msg.get('error') + m = "Incorrect Answer: Line number(s) 2 did not match." assert not success - m = dedent("""\ - ERROR: - Expected: - 5 - 5 - - Given: - 5 - 6 - - Error in line 2 of output. - Expected line 2: - 5 - Given line 2: - 6 - """) - assert m == msg + assert m == error_msg |