From e09638f16f972a011c00110ace30aad6418850bd Mon Sep 17 00:00:00 2001 From: Christoph Schindler Date: Sun, 28 May 2017 10:04:20 +0200 Subject: [PATCH] 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. --- exercises/grade-school/grade_school_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/grade-school/grade_school_test.py b/exercises/grade-school/grade_school_test.py index 29540a92..6090f24b 100644 --- a/exercises/grade-school/grade_school_test.py +++ b/exercises/grade-school/grade_school_test.py @@ -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()