@@ -170,6 +170,10 @@ def _process_markers(self, item):
170170 self .results [item .nodeid ]["errors" ] += f"\n \n { marker .args [0 ]} "
171171 else :
172172 self .results [item .nodeid ]["errors" ] = marker .args [0 ]
173+ elif marker .name == "markus_marks_total" and marker .args != [] and item .nodeid in self .results :
174+ self .results [item .nodeid ]["marks_total" ] = marker .args [0 ]
175+ elif marker .name == "markus_marks_earned" and marker .args != [] and item .nodeid in self .results :
176+ self .results [item .nodeid ]["marks_earned" ] = marker .args [0 ]
173177
174178 def pytest_collectreport (self , report ):
175179 """
@@ -214,6 +218,12 @@ def __init__(
214218 self .message = result ["errors" ]
215219 super ().__init__ (tester )
216220
221+ # Override self.points_total attribute (set in Test initializer)
222+ if "marks_total" in result :
223+ self .points_total = result ["marks_total" ]
224+
225+ self .points_earned = result .get ("marks_earned" )
226+
217227 @property
218228 def test_name (self ) -> str :
219229 """The name of this test"""
@@ -226,7 +236,12 @@ def run(self) -> str:
226236 """
227237 Return a json string containing all test result information.
228238 """
229- if self .status == "success" :
239+ if self .points_earned is not None and 0 < self .points_earned < self .points_total :
240+ return self .partially_passed (points_earned = self .points_earned , message = self .message )
241+ elif self .points_earned is not None and self .points_earned > self .points_total :
242+ bonus = self .points_earned - self .points_total
243+ return self .passed_with_bonus (points_bonus = bonus , message = self .message )
244+ elif self .status == "success" :
230245 return self .passed (message = self .message )
231246 elif self .status == "failure" :
232247 return self .failed (message = self .message )
0 commit comments