Use explicit values in test assertions. BOM-683
Python 3 changed how rounding is performed. In Python 2, .625 rounded to .63 (as our grading code rounds it, so the test passed). In Python 3, .625 rounds to .62. This fixes the test by avoiding round() to calculate the expected value, and instead simply using the value we expect.
This commit is contained in:
@@ -1187,10 +1187,11 @@ class TestConditionalContent(TestSubmittingProblems):
|
||||
self.assertEqual(self.score_for_hw('homework2'), [1.0, 2.0])
|
||||
self.assertEqual(self.earned_hw_scores(), [1.0, 3.0])
|
||||
|
||||
# Grade percent is .63. Here is the calculation
|
||||
homework_1_score = 1.0 / 2
|
||||
homework_2_score = (1.0 + 2.0) / 4
|
||||
self.check_grade_percent(round((homework_1_score + homework_2_score) / 2, 2))
|
||||
# Grade percent is .63. Here is the calculation:
|
||||
# homework_1_score = 1.0 / 2
|
||||
# homework_2_score = (1.0 + 2.0) / 4
|
||||
# round((homework_1_score + homework_2_score) / 2) == .63
|
||||
self.check_grade_percent(.63)
|
||||
|
||||
def test_split_different_problems_group_1(self):
|
||||
"""
|
||||
@@ -1205,10 +1206,11 @@ class TestConditionalContent(TestSubmittingProblems):
|
||||
self.assertEqual(self.score_for_hw('homework2'), [1.0])
|
||||
self.assertEqual(self.earned_hw_scores(), [1.0, 1.0])
|
||||
|
||||
# Grade percent is .75. Here is the calculation
|
||||
homework_1_score = 1.0 / 2
|
||||
homework_2_score = 1.0 / 1
|
||||
self.check_grade_percent(round((homework_1_score + homework_2_score) / 2, 2))
|
||||
# Grade percent is .75. Here is the calculation:
|
||||
# homework_1_score = 1.0 / 2
|
||||
# homework_2_score = 1.0 / 1
|
||||
# round((homework_1_score + homework_2_score) / 2) == .75
|
||||
self.check_grade_percent(.75)
|
||||
|
||||
def split_one_group_no_problems_setup(self, user_partition_group):
|
||||
"""
|
||||
@@ -1238,10 +1240,11 @@ class TestConditionalContent(TestSubmittingProblems):
|
||||
self.assertEqual(self.score_for_hw('homework2'), [])
|
||||
self.assertEqual(self.earned_hw_scores(), [1.0])
|
||||
|
||||
# Grade percent is .25. Here is the calculation.
|
||||
homework_1_score = 1.0 / 2
|
||||
homework_2_score = 0.0
|
||||
self.check_grade_percent(round((homework_1_score + homework_2_score) / 2, 2))
|
||||
# Grade percent is .25. Here is the calculation:
|
||||
# homework_1_score = 1.0 / 2
|
||||
# homework_2_score = 0.0
|
||||
# round((homework_1_score + homework_2_score) / 2) == .25
|
||||
self.check_grade_percent(.25)
|
||||
|
||||
def test_split_one_group_no_problems_group_1(self):
|
||||
"""
|
||||
@@ -1256,6 +1259,7 @@ class TestConditionalContent(TestSubmittingProblems):
|
||||
self.assertEqual(self.earned_hw_scores(), [1.0, 1.0])
|
||||
|
||||
# Grade percent is .75. Here is the calculation.
|
||||
homework_1_score = 1.0 / 2
|
||||
homework_2_score = 1.0 / 1
|
||||
self.check_grade_percent(round((homework_1_score + homework_2_score) / 2, 2))
|
||||
# homework_1_score = 1.0 / 2
|
||||
# homework_2_score = 1.0 / 1
|
||||
# round((homework_1_score + homework_2_score) / 2) == .75
|
||||
self.check_grade_percent(.75)
|
||||
|
||||
Reference in New Issue
Block a user