33 GitAutograderOutput ,
44 GitAutograderExercise ,
55 GitAutograderStatus ,
6- GitAutograderCommit
6+ GitAutograderCommit ,
77)
88from itertools import zip_longest
99
@@ -89,7 +89,12 @@ def get_commit_from_message(
8989 return None
9090
9191
92- def verify_commit_file_content (exercise : GitAutograderExercise , commit : GitAutograderCommit | None , file_name : str , expected_content : List [str ]):
92+ def verify_commit_file_content (
93+ exercise : GitAutograderExercise ,
94+ commit : GitAutograderCommit | None ,
95+ file_name : str ,
96+ expected_content : List [str ],
97+ ):
9398 """Checkout to specific commit and verify that the file content of the given commit matches the expected content."""
9499 if not commit :
95100 return
@@ -100,7 +105,13 @@ def verify_commit_file_content(exercise: GitAutograderExercise, commit: GitAutog
100105
101106 contents = [line .strip () for line in file .readlines () if line .strip () != "" ]
102107 if contents != expected_content :
103- raise exercise .wrong_answer ([FEATURES_FILE_CONTENT_INVALID .format (commit = commit .commit .message .strip ())])
108+ raise exercise .wrong_answer (
109+ [
110+ FEATURES_FILE_CONTENT_INVALID .format (
111+ commit = commit .commit .message .strip ()
112+ )
113+ ]
114+ )
104115 exercise .repo .branches .branch ("main" ).checkout ()
105116
106117
@@ -143,21 +154,33 @@ def verify(exercise: GitAutograderExercise) -> GitAutograderOutput:
143154 # Verify that the features.md file is correct
144155 # Checkout to specific commit to verify the contents of features.md
145156 features_commit = get_commit_from_message (commits , "Add features.md" )
146- verify_commit_file_content (exercise , features_commit , "features.md" , EXPECTED_LINES_FEATURES_COMMIT )
157+ verify_commit_file_content (
158+ exercise , features_commit , "features.md" , EXPECTED_LINES_FEATURES_COMMIT
159+ )
147160
148- create_books_commit = get_commit_from_message (commits , "Mention feature for creating books" )
149- verify_commit_file_content (exercise , create_books_commit , "features.md" , EXPECTED_LINES_CREATE_BOOK_COMMIT )
161+ create_books_commit = get_commit_from_message (
162+ commits , "Mention feature for creating books"
163+ )
164+ verify_commit_file_content (
165+ exercise , create_books_commit , "features.md" , EXPECTED_LINES_CREATE_BOOK_COMMIT
166+ )
150167
151168 fix_heading_commit = get_commit_from_message (commits , "Fix phrasing of heading" )
152- verify_commit_file_content (exercise , fix_heading_commit , "features.md" , EXPECTED_LINES_FIX_HEADING_COMMIT )
169+ verify_commit_file_content (
170+ exercise , fix_heading_commit , "features.md" , EXPECTED_LINES_FIX_HEADING_COMMIT
171+ )
153172
154173 add_search_commit = get_commit_from_message (commits , "Add the search feature" )
155- verify_commit_file_content (exercise , add_search_commit , "features.md" , EXPECTED_LINES_SEARCH_COMMIT )
174+ verify_commit_file_content (
175+ exercise , add_search_commit , "features.md" , EXPECTED_LINES_SEARCH_COMMIT
176+ )
156177
157178 delete_feature_commit = get_commit_from_message (commits , "Add the delete feature" )
158- verify_commit_file_content (exercise , delete_feature_commit , "features.md" , EXPECTED_LINES_DELETE_COMMIT )
179+ verify_commit_file_content (
180+ exercise , delete_feature_commit , "features.md" , EXPECTED_LINES_DELETE_COMMIT
181+ )
159182
160183 return exercise .to_output (
161- ["You have successfully completed the exercise!" ],
162- GitAutograderStatus .SUCCESSFUL
184+ ["You have successfully completed the exercise!" ],
185+ GitAutograderStatus .SUCCESSFUL ,
163186 )
0 commit comments