summaryrefslogtreecommitdiff
path: root/yaksh/evaluator_tests
diff options
context:
space:
mode:
Diffstat (limited to 'yaksh/evaluator_tests')
-rw-r--r--yaksh/evaluator_tests/test_bash_evaluation.py3
-rw-r--r--yaksh/evaluator_tests/test_c_cpp_evaluation.py14
-rw-r--r--yaksh/evaluator_tests/test_java_evaluation.py7
-rw-r--r--yaksh/evaluator_tests/test_python_evaluation.py4
-rw-r--r--yaksh/evaluator_tests/test_python_stdio_evaluator.py39
5 files changed, 24 insertions, 43 deletions
diff --git a/yaksh/evaluator_tests/test_bash_evaluation.py b/yaksh/evaluator_tests/test_bash_evaluation.py
index 8bb8c81..6e7410e 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_msg')
+ 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..5ff4e4c 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_line_numbers'))
+ result_error = result.get('error')[0].get('error_msg')
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_line_numbers'))
+ result_error = result.get('error')[0].get('error_msg')
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..c733586 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_line_numbers'))
+ result_error = result.get('error')[0].get('error_msg')
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..a2faf77 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_msg')
)
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..8877544 100644
--- a/yaksh/evaluator_tests/test_python_stdio_evaluator.py
+++ b/yaksh/evaluator_tests/test_python_stdio_evaluator.py
@@ -1,7 +1,4 @@
-from textwrap import dedent
-
-from yaksh.python_stdio_evaluator import compare_outputs
-
+from yaksh.compare_stdio import compare_outputs
def test_compare_outputs():
exp = "5\n5\n"
@@ -27,36 +24,16 @@ def test_compare_outputs():
exp = "5\n5\n"
given = "5 5"
success, msg = compare_outputs(given, exp)
+ error_msg = msg.get('error_msg')
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)
+ error_msg = msg.get('error_msg')
+ 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