From 683cc77b3c5c8d7f63d8fd8384cc03d5ee089b43 Mon Sep 17 00:00:00 2001 From: adityacp Date: Tue, 29 May 2018 12:48:24 +0530 Subject: Add tests for bash evaluator --- yaksh/evaluator_tests/test_bash_evaluation.py | 52 +++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'yaksh/evaluator_tests') diff --git a/yaksh/evaluator_tests/test_bash_evaluation.py b/yaksh/evaluator_tests/test_bash_evaluation.py index 19f9fb2..f86bf24 100644 --- a/yaksh/evaluator_tests/test_bash_evaluation.py +++ b/yaksh/evaluator_tests/test_bash_evaluation.py @@ -58,6 +58,58 @@ class BashAssertionEvaluationTestCases(EvaluatorBaseTest): # Then self.assertTrue(result.get('success')) + def test_correct_answer_without_test_case_args(self): + # Given + user_answer = "echo 'hello'" + tc_data = "echo 'hello'" + self.test_case_data = [ + {"test_case": tc_data, + "test_case_args": "", + "test_case_type": "standardtestcase", + "weight": 0.0 + } + ] + kwargs = {'metadata': { + 'user_answer': user_answer, + 'file_paths': self.file_paths, + 'partial_grading': False, + 'language': 'bash' + }, 'test_case_data': self.test_case_data, + } + + # When + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) + + # Then + self.assertTrue(result.get('success')) + + def test_incorrect_answer_without_test_case_args(self): + # Given + user_answer = "echo 'hello'" + tc_data = "echo 'hello world'" + self.test_case_data = [ + {"test_case": tc_data, + "test_case_args": "", + "test_case_type": "standardtestcase", + "weight": 0.0 + } + ] + kwargs = {'metadata': { + 'user_answer': user_answer, + 'file_paths': self.file_paths, + 'partial_grading': False, + 'language': 'bash' + }, 'test_case_data': self.test_case_data, + } + + # When + grader = Grader(self.in_dir) + result = grader.evaluate(kwargs) + + # Then + self.assertFalse(result.get('success')) + def test_error(self): # Given user_answer = ("#!/bin/bash\n[[ $# -eq 2 ]] " -- cgit