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:
Christoph Schindler
2017-05-28 10:04:20 +02:00
committed by Tammo Behrends
parent 080e433667
commit e09638f16f

View File

@@ -45,8 +45,8 @@ class SchoolTest(unittest.TestCase):
students = [(3, ("Kyle", )), (4, ("Christopher", "Jennifer", )),
(6, ("Kareem", ))]
for grade, students_in_grade in students:
for student in students_in_grade:
for grade, students_in_grade in students[::-1]:
for student in students_in_grade[::-1]:
self.school.add(student, grade)
result = self.school.sort()