diff options
author | adityacp | 2016-06-20 14:57:21 +0530 |
---|---|---|
committer | adityacp | 2016-07-28 15:56:06 +0530 |
commit | d8876ae789197de4d977d28f0c0ff04cf39c2c35 (patch) | |
tree | a4dcaa8b0452fa41e73bd7593d77d1b2818ca3ab /yaksh/evaluator_tests/test_bash_evaluation.py | |
parent | 98cda0357f238cd230c26eebbf75e1d90bc3588e (diff) | |
download | online_test-d8876ae789197de4d977d28f0c0ff04cf39c2c35.tar.gz online_test-d8876ae789197de4d977d28f0c0ff04cf39c2c35.tar.bz2 online_test-d8876ae789197de4d977d28f0c0ff04cf39c2c35.zip |
added test cases for file based questions
Diffstat (limited to 'yaksh/evaluator_tests/test_bash_evaluation.py')
-rw-r--r-- | yaksh/evaluator_tests/test_bash_evaluation.py | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/yaksh/evaluator_tests/test_bash_evaluation.py b/yaksh/evaluator_tests/test_bash_evaluation.py index 4ff3e0a..1070c6a 100644 --- a/yaksh/evaluator_tests/test_bash_evaluation.py +++ b/yaksh/evaluator_tests/test_bash_evaluation.py @@ -8,10 +8,11 @@ class BashEvaluationTestCases(unittest.TestCase): self.test_case_data = [ {"test_case": "bash_files/sample.sh,bash_files/sample.args"} ] - self.in_dir = "/tmp" + self.in_dir = os.getcwd() self.timeout_msg = ("Code took more than {0} seconds to run. " "You probably have an infinite loop in your" " code.").format(SERVER_TIMEOUT) + self.file_paths = None def test_correct_answer(self): user_answer = ("#!/bin/bash\n[[ $# -eq 2 ]]" @@ -19,7 +20,8 @@ class BashEvaluationTestCases(unittest.TestCase): ) get_class = BashCodeEvaluator(self.in_dir) kwargs = {'user_answer': user_answer, - 'test_case_data': self.test_case_data + 'test_case_data': self.test_case_data, + 'file_paths': self.file_paths } result = get_class.evaluate(**kwargs) self.assertTrue(result.get('success')) @@ -30,7 +32,8 @@ class BashEvaluationTestCases(unittest.TestCase): "&& echo $(( $1 - $2 )) && exit $(( $1 - $2 ))") get_class = BashCodeEvaluator(self.in_dir) kwargs = {'user_answer': user_answer, - 'test_case_data': self.test_case_data + 'test_case_data': self.test_case_data, + 'file_paths': self.file_paths } result = get_class.evaluate(**kwargs) self.assertFalse(result.get("success")) @@ -41,12 +44,27 @@ class BashEvaluationTestCases(unittest.TestCase): " do echo "" > /dev/null ; done") get_class = BashCodeEvaluator(self.in_dir) kwargs = {'user_answer': user_answer, - 'test_case_data': self.test_case_data + 'test_case_data': self.test_case_data, + 'file_paths': self.file_paths } result = get_class.evaluate(**kwargs) self.assertFalse(result.get("success")) self.assertEquals(result.get("error"), self.timeout_msg) + def test_file_based_assert(self): + self.file_paths = [(os.getcwd()+"/yaksh/test.txt", False)] + self.test_case_data = [ + {"test_case": "bash_files/sample1.sh,bash_files/sample1.args"} + ] + user_answer = ("#!/bin/bash\ncat $1") + get_class = BashCodeEvaluator() + kwargs = {'user_answer': user_answer, + 'test_case_data': self.test_case_data, + 'file_paths': self.file_paths + } + result = get_class.evaluate(**kwargs) + self.assertTrue(result.get("success")) + self.assertEquals(result.get("error"), "Correct answer") if __name__ == '__main__': unittest.main() |