summaryrefslogtreecommitdiff
path: root/yaksh/evaluator_tests/test_bash_evaluation.py
diff options
context:
space:
mode:
authorankitjavalkar2016-11-04 18:07:35 +0530
committerankitjavalkar2016-11-10 12:43:14 +0530
commit576c92b3b7d8989bf6bb99316d096f48f5b4cc24 (patch)
treef1f36b8cae1c9ffad9c5cb5637e857ad9b01aba4 /yaksh/evaluator_tests/test_bash_evaluation.py
parent0bfa58d8705fa08b45a208a4cec98dd267799f8a (diff)
downloadonline_test-576c92b3b7d8989bf6bb99316d096f48f5b4cc24.tar.gz
online_test-576c92b3b7d8989bf6bb99316d096f48f5b4cc24.tar.bz2
online_test-576c92b3b7d8989bf6bb99316d096f48f5b4cc24.zip
Fix test cases for partial grading feature
Diffstat (limited to 'yaksh/evaluator_tests/test_bash_evaluation.py')
-rw-r--r--yaksh/evaluator_tests/test_bash_evaluation.py59
1 files changed, 39 insertions, 20 deletions
diff --git a/yaksh/evaluator_tests/test_bash_evaluation.py b/yaksh/evaluator_tests/test_bash_evaluation.py
index 66ade19..5f4be4b 100644
--- a/yaksh/evaluator_tests/test_bash_evaluation.py
+++ b/yaksh/evaluator_tests/test_bash_evaluation.py
@@ -13,12 +13,12 @@ class BashAssertionEvaluationTestCases(unittest.TestCase):
def setUp(self):
with open('/tmp/test.txt', 'wb') as f:
f.write('2'.encode('ascii'))
- tmp_in_dir_path = tempfile.mkdtemp()
self.test_case_data = [
- {"test_case": "bash_files/sample.sh,bash_files/sample.args"}
+ {"test_case": "bash_files/sample.sh,bash_files/sample.args",
+ "marks": 0.0
+ }
]
- tmp_in_dir_path = tempfile.mkdtemp()
- self.in_dir = tmp_in_dir_path
+ self.in_dir = tempfile.mkdtemp()
self.timeout_msg = ("Code took more than {0} seconds to run. "
"You probably have an infinite loop in your"
" code.").format(SERVER_TIMEOUT)
@@ -33,7 +33,8 @@ class BashAssertionEvaluationTestCases(unittest.TestCase):
" && echo $(( $1 + $2 )) && exit $(( $1 + $2 ))"
)
get_class = BashCodeEvaluator(self.in_dir)
- kwargs = {'user_answer': user_answer,
+ kwargs = {'user_answer': user_answer,
+ 'partial_grading': True,
'test_case_data': self.test_case_data,
'file_paths': self.file_paths
}
@@ -45,7 +46,8 @@ class BashAssertionEvaluationTestCases(unittest.TestCase):
user_answer = ("#!/bin/bash\n[[ $# -eq 2 ]] "
"&& echo $(( $1 - $2 )) && exit $(( $1 - $2 ))")
get_class = BashCodeEvaluator(self.in_dir)
- kwargs = {'user_answer': user_answer,
+ kwargs = {'user_answer': user_answer,
+ 'partial_grading': True,
'test_case_data': self.test_case_data,
'file_paths': self.file_paths
}
@@ -57,7 +59,8 @@ class BashAssertionEvaluationTestCases(unittest.TestCase):
user_answer = ("#!/bin/bash\nwhile [ 1 ] ;"
" do echo "" > /dev/null ; done")
get_class = BashCodeEvaluator(self.in_dir)
- kwargs = {'user_answer': user_answer,
+ kwargs = {'user_answer': user_answer,
+ 'partial_grading': True,
'test_case_data': self.test_case_data,
'file_paths': self.file_paths
}
@@ -68,11 +71,14 @@ class BashAssertionEvaluationTestCases(unittest.TestCase):
def test_file_based_assert(self):
self.file_paths = [('/tmp/test.txt', False)]
self.test_case_data = [
- {"test_case": "bash_files/sample1.sh,bash_files/sample1.args"}
+ {"test_case": "bash_files/sample1.sh,bash_files/sample1.args",
+ "marks": 0.0
+ }
]
user_answer = ("#!/bin/bash\ncat $1")
get_class = BashCodeEvaluator()
kwargs = {'user_answer': user_answer,
+ 'partial_grading': True,
'test_case_data': self.test_case_data,
'file_paths': self.file_paths
}
@@ -82,6 +88,7 @@ class BashAssertionEvaluationTestCases(unittest.TestCase):
class BashStdioEvaluationTestCases(unittest.TestCase):
def setUp(self):
+ self.in_dir = tempfile.mkdtemp()
self.timeout_msg = ("Code took more than {0} seconds to run. "
"You probably have an infinite loop in your"
" code.").format(SERVER_TIMEOUT)
@@ -93,11 +100,15 @@ class BashStdioEvaluationTestCases(unittest.TestCase):
echo -n `expr $A + $B`
"""
)
- test_case_data = [{'expected_output': '11', 'expected_input': '5\n6'}]
+ test_case_data = [{'expected_output': '11',
+ 'expected_input': '5\n6',
+ 'marks': 0.0
+ }]
get_class = BashStdioEvaluator()
kwargs = {"user_answer": user_answer,
- "test_case_data": test_case_data
- }
+ "partial_grading": True,
+ "test_case_data": test_case_data
+ }
result = get_class.evaluate(**kwargs)
self.assertEqual(result.get('error'), "Correct answer")
self.assertTrue(result.get('success'))
@@ -112,12 +123,14 @@ class BashStdioEvaluationTestCases(unittest.TestCase):
"""
)
test_case_data = [{'expected_output': '1 2 3\n4 5 6\n7 8 9\n',
- 'expected_input': '1,2,3\n4,5,6\n7,8,9'
+ 'expected_input': '1,2,3\n4,5,6\n7,8,9',
+ 'marks': 0.0
}]
get_class = BashStdioEvaluator()
kwargs = {"user_answer": user_answer,
- "test_case_data": test_case_data
- }
+ "partial_grading": True,
+ "test_case_data": test_case_data
+ }
result = get_class.evaluate(**kwargs)
self.assertEqual(result.get('error'), "Correct answer")
self.assertTrue(result.get('success'))
@@ -129,11 +142,15 @@ class BashStdioEvaluationTestCases(unittest.TestCase):
echo -n `expr $A - $B`
"""
)
- test_case_data = [{'expected_output': '11', 'expected_input': '5\n6'}]
+ test_case_data = [{'expected_output': '11',
+ 'expected_input': '5\n6',
+ 'marks': 0.0
+ }]
get_class = BashStdioEvaluator()
kwargs = {"user_answer": user_answer,
- "test_case_data": test_case_data
- }
+ "partial_grading": True,
+ "test_case_data": test_case_data
+ }
result = get_class.evaluate(**kwargs)
self.assertIn("Incorrect", result.get('error'))
self.assertFalse(result.get('success'))
@@ -146,12 +163,14 @@ class BashStdioEvaluationTestCases(unittest.TestCase):
"""
)
test_case_data = [{'expected_output': '10',
- 'expected_input': ''
+ 'expected_input': '',
+ 'marks': 0.0
}]
get_class = BashStdioEvaluator()
kwargs = {"user_answer": user_answer,
- "test_case_data": test_case_data
- }
+ "partial_grading": True,
+ "test_case_data": test_case_data
+ }
result = get_class.evaluate(**kwargs)
self.assertEqual(result.get('error'), "Correct answer")
self.assertTrue(result.get('success'))