grade-school: Catch false positives due to test case being sorted already (#467)
From Python 3.6 on, dictionaries retain the order in which items are added. If the test case puts the items into the tested class in sorted order, even a naive implementation (one that does no sorting) can pass by giving back all items in the original order.
This commit is contained in:
committed by
Tammo Behrends
parent
080e433667
commit
e09638f16f
@@ -45,8 +45,8 @@ class SchoolTest(unittest.TestCase):
|
|||||||
students = [(3, ("Kyle", )), (4, ("Christopher", "Jennifer", )),
|
students = [(3, ("Kyle", )), (4, ("Christopher", "Jennifer", )),
|
||||||
(6, ("Kareem", ))]
|
(6, ("Kareem", ))]
|
||||||
|
|
||||||
for grade, students_in_grade in students:
|
for grade, students_in_grade in students[::-1]:
|
||||||
for student in students_in_grade:
|
for student in students_in_grade[::-1]:
|
||||||
self.school.add(student, grade)
|
self.school.add(student, grade)
|
||||||
|
|
||||||
result = self.school.sort()
|
result = self.school.sort()
|
||||||
|
|||||||
Reference in New Issue
Block a user