diff options
author | maheshgudi | 2016-08-03 15:16:08 +0530 |
---|---|---|
committer | maheshgudi | 2016-08-03 15:16:08 +0530 |
commit | 40fbb5d8f1d4174f7d7e2d4723e9fbfc40040dcb (patch) | |
tree | 7885b674d2deb064137f1f501ed1707bfd54daf8 /yaksh/evaluator_tests/test_bash_evaluation.py | |
parent | 1b71abc9437d721a41f017db406f312755f5a4c4 (diff) | |
parent | 2b03aeb36fa333ea1644a248c742cf0c1df12a5f (diff) | |
download | online_test-40fbb5d8f1d4174f7d7e2d4723e9fbfc40040dcb.tar.gz online_test-40fbb5d8f1d4174f7d7e2d4723e9fbfc40040dcb.tar.bz2 online_test-40fbb5d8f1d4174f7d7e2d4723e9fbfc40040dcb.zip |
rebase changes with stdio evaluator
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 ee6c1f0..addc5e6 100644 --- a/yaksh/evaluator_tests/test_bash_evaluation.py +++ b/yaksh/evaluator_tests/test_bash_evaluation.py @@ -11,10 +11,11 @@ class BashAssertionEvaluationTestCases(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 ]]" @@ -22,7 +23,8 @@ class BashAssertionEvaluationTestCases(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')) @@ -33,7 +35,8 @@ class BashAssertionEvaluationTestCases(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")) @@ -44,12 +47,27 @@ class BashAssertionEvaluationTestCases(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") class BashStdioEvaluationTestCases(unittest.TestCase): def setUp(self): |