summaryrefslogtreecommitdiff
path: root/yaksh/evaluator_tests
diff options
context:
space:
mode:
authorankitjavalkar2016-11-16 20:32:21 +0530
committerankitjavalkar2016-11-16 20:32:21 +0530
commitcb9a541a4653b2ed13db3a6171b50de575b0f05d (patch)
tree9fcab71c37e49ac1dfe61ba35fb97b50a32aaa25 /yaksh/evaluator_tests
parent0b151541d9414572965b597815f98c4b057430e1 (diff)
downloadonline_test-cb9a541a4653b2ed13db3a6171b50de575b0f05d.tar.gz
online_test-cb9a541a4653b2ed13db3a6171b50de575b0f05d.tar.bz2
online_test-cb9a541a4653b2ed13db3a6171b50de575b0f05d.zip
Fix Output display of Code Question
Diffstat (limited to 'yaksh/evaluator_tests')
-rw-r--r--yaksh/evaluator_tests/test_python_evaluation.py44
1 files changed, 37 insertions, 7 deletions
diff --git a/yaksh/evaluator_tests/test_python_evaluation.py b/yaksh/evaluator_tests/test_python_evaluation.py
index a0e3713..a3a0be8 100644
--- a/yaksh/evaluator_tests/test_python_evaluation.py
+++ b/yaksh/evaluator_tests/test_python_evaluation.py
@@ -45,7 +45,7 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase):
# Then
self.assertTrue(result.get('success'))
- self.assertEqual(result.get('error'), "Correct answer")
+ self.assertIn("Correct answer", result.get('error'))
def test_incorrect_answer(self):
# Given
@@ -62,12 +62,42 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase):
# Then
self.assertFalse(result.get('success'))
- self.assertEqual(result.get('error'),
- ('AssertionError in: assert(add(1,2)==3)\n'
- 'AssertionError in: assert(add(-1,2)==1)\n'
- 'AssertionError in: assert(add(-1,-2)==-3)\n'
- )
- )
+ self.assertIn('AssertionError in: assert(add(1,2)==3)',
+ result.get('error')
+ )
+ self.assertIn('AssertionError in: assert(add(-1,2)==1)',
+ result.get('error')
+ )
+ self.assertIn('AssertionError in: assert(add(-1,-2)==-3)',
+ result.get('error')
+ )
+
+ def test_partial_incorrect_answer(self):
+ # Given
+ user_answer = "def add(a,b):\n\treturn abs(a) + abs(b)"
+ test_case_data = [{"test_case": 'assert(add(-1,2)==1)', 'weight': 1.0},
+ {"test_case": 'assert(add(-1,-2)==-3)', 'weight': 1.0},
+ {"test_case": 'assert(add(1,2)==3)', 'weight': 2.0}
+ ]
+ kwargs = {'user_answer': user_answer,
+ 'test_case_data': test_case_data,
+ 'file_paths': self.file_paths,
+ 'partial_grading': True
+ }
+
+ # When
+ evaluator = PythonAssertionEvaluator()
+ result = evaluator.evaluate(**kwargs)
+
+ # Then
+ self.assertFalse(result.get('success'))
+ self.assertEqual(result.get('weight'), 2.0)
+ self.assertIn('AssertionError in: assert(add(-1,2)==1)',
+ result.get('error')
+ )
+ self.assertIn('AssertionError in: assert(add(-1,-2)==-3)',
+ result.get('error')
+ )
def test_infinite_loop(self):
# Given