@@ -103,6 +103,7 @@ def __init__(self) -> None:
103103 self .results = {}
104104 self .tags = set ()
105105 self .annotations = []
106+ self .extra_marks = {}
106107 self .overall_comments = []
107108
108109 def pytest_configure (self , config ):
@@ -181,18 +182,18 @@ def _process_markers(self, item):
181182 self .results [item .nodeid ]["marks_earned" ] = marker .args [0 ]
182183 elif marker .name == "markus_extra_marks" and marker .args != [] and item .nodeid in self .results :
183184 self .results [item .nodeid ]["marks_earned" ] += marker .args [0 ]
184- bonus_comment = {
185+ extra_mark = {
185186 "id" : str (uuid .uuid4 ()),
186187 "mark" : marker .args [0 ],
187188 "fn" : item .nodeid ,
188189 "description" : marker .args [1 ],
189190 "unit" : marker .args [2 ] if len (marker .args ) > 2 else "points" ,
190191 }
191192
192- if self .results [ item . nodeid ]. get ("bonus_comments" ):
193- self .results [item .nodeid ][ "bonus_comments" ] .append (bonus_comment )
193+ if self .extra_marks . get (item . nodeid ):
194+ self .extra_marks [item .nodeid ].append (extra_mark )
194195 else :
195- self .results [item .nodeid ][ "bonus_comments" ] = [bonus_comment ]
196+ self .extra_marks [item .nodeid ] = [extra_mark ]
196197
197198 def pytest_collectreport (self , report ):
198199 """
@@ -282,6 +283,7 @@ def __init__(
282283 """
283284 super ().__init__ (specs , test_class , resource_settings = resource_settings )
284285 self .annotations = []
286+ self .extra_marks = {}
285287 self .overall_comments = []
286288 self .tags = set ()
287289
@@ -326,6 +328,7 @@ def _run_pytest_tests(self, test_file: str) -> List[Dict]:
326328 results .extend (plugin .results .values ())
327329 self .annotations = plugin .annotations
328330 self .overall_comments = plugin .overall_comments
331+ self .extra_marks = plugin .extra_marks
329332 self .tags = plugin .tags
330333 finally :
331334 sys .stdout = sys .__stdout__
@@ -363,3 +366,5 @@ def after_tester_run(self) -> None:
363366 print (self .test_class .format_tags (self .tags ))
364367 if self .overall_comments :
365368 print (self .test_class .format_overall_comment (self .overall_comments , separator = "\n \n " ))
369+ if self .extra_marks :
370+ print (self .test_class .format_extra_marks (self .extra_marks ))
0 commit comments