summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/compare_stdio.py4
-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.py51
6 files changed, 32 insertions, 51 deletions
diff --git a/yaksh/compare_stdio.py b/yaksh/compare_stdio.py
index ba258c3..3b1b998 100644
--- a/yaksh/compare_stdio.py
+++ b/yaksh/compare_stdio.py
@@ -29,13 +29,13 @@ class CompareOutputs(object):
if ng != ne:
err_line_no = self._incorrect_user_lines(exp_lines, given_lines)
msg["error_no"] = err_line_no
- msg["error"] = "We had expected {0} number of lines. We got {1} number of lines.".format(ne, ng)
+ msg["error"] = "Incorrect Answer: We had expected {0} number of lines. We got {1} number of lines.".format(ne, ng)
return False, msg
else:
err_line_no = self._incorrect_user_lines(exp_lines, given_lines)
if err_line_no:
msg["error_no"] = err_line_no
- msg["error"] = "Line number(s) {0} did not match."\
+ msg["error"] = "Incorrect Answer: Line number(s) {0} did not match."\
.format(", ".join(map(str,[x+1 for x in err_line_no])))
return False, msg
else:
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