summaryrefslogtreecommitdiff
path: root/yaksh/evaluator_tests/test_bash_evaluation.py
diff options
context:
space:
mode:
Diffstat (limited to 'yaksh/evaluator_tests/test_bash_evaluation.py')
-rw-r--r--yaksh/evaluator_tests/test_bash_evaluation.py16
1 files changed, 6 insertions, 10 deletions
diff --git a/yaksh/evaluator_tests/test_bash_evaluation.py b/yaksh/evaluator_tests/test_bash_evaluation.py
index 5022c1d..4b551d7 100644
--- a/yaksh/evaluator_tests/test_bash_evaluation.py
+++ b/yaksh/evaluator_tests/test_bash_evaluation.py
@@ -6,11 +6,12 @@ import tempfile
from yaksh.grader import Grader
from yaksh.bash_code_evaluator import BashCodeEvaluator
from yaksh.bash_stdio_evaluator import BashStdIOEvaluator
+from yaksh.evaluator_tests.test_python_evaluation import EvaluatorBaseTest
from yaksh.settings import SERVER_TIMEOUT
from textwrap import dedent
-class BashAssertionEvaluationTestCases(unittest.TestCase):
+class BashAssertionEvaluationTestCases(EvaluatorBaseTest):
def setUp(self):
self.f_path = os.path.join(tempfile.gettempdir(), "test.txt")
with open(self.f_path, 'wb') as f:
@@ -58,7 +59,6 @@ class BashAssertionEvaluationTestCases(unittest.TestCase):
# Then
self.assertTrue(result.get('success'))
- self.assertEqual(result.get('error'), "Correct answer\n")
def test_error(self):
# Given
@@ -80,7 +80,7 @@ class BashAssertionEvaluationTestCases(unittest.TestCase):
# Then
self.assertFalse(result.get("success"))
- self.assertTrue("Error" in result.get("error"))
+ self.assert_correct_output("Error", result.get("error"))
def test_infinite_loop(self):
# Given
@@ -102,7 +102,7 @@ class BashAssertionEvaluationTestCases(unittest.TestCase):
# Then
self.assertFalse(result.get("success"))
- self.assertEqual(result.get("error"), self.timeout_msg)
+ self.assert_correct_output(self.timeout_msg, result.get("error"))
def test_file_based_assert(self):
# Given
@@ -136,9 +136,8 @@ class BashAssertionEvaluationTestCases(unittest.TestCase):
# Then
self.assertTrue(result.get("success"))
- self.assertEqual(result.get("error"), "Correct answer\n")
-class BashStdIOEvaluationTestCases(unittest.TestCase):
+class BashStdIOEvaluationTestCases(EvaluatorBaseTest):
def setUp(self):
self.in_dir = tempfile.mkdtemp()
self.timeout_msg = ("Code took more than {0} seconds to run. "
@@ -175,7 +174,6 @@ class BashStdIOEvaluationTestCases(unittest.TestCase):
result = grader.evaluate(kwargs)
# Then
- self.assertEqual(result.get('error'), "Correct answer\n")
self.assertTrue(result.get('success'))
def test_array_input(self):
@@ -208,7 +206,6 @@ class BashStdIOEvaluationTestCases(unittest.TestCase):
result = grader.evaluate(kwargs)
# Then
- self.assertEqual(result.get('error'), "Correct answer\n")
self.assertTrue(result.get('success'))
def test_incorrect_answer(self):
@@ -239,7 +236,7 @@ class BashStdIOEvaluationTestCases(unittest.TestCase):
result = grader.evaluate(kwargs)
# Then
- self.assertIn("Incorrect", result.get('error'))
+ self.assert_correct_output("Incorrect", result.get('error'))
self.assertFalse(result.get('success'))
def test_stdout_only(self):
@@ -270,7 +267,6 @@ class BashStdIOEvaluationTestCases(unittest.TestCase):
result = grader.evaluate(kwargs)
# Then
- self.assertEqual(result.get('error'), "Correct answer\n")
self.assertTrue(result.get('success'))
if __name__ == '__main__':