@@ -20,7 +20,8 @@ def test_function(name,
2020 incorrect_msg = None ,
2121 add_more = False ,
2222 highlight = True ,
23- state = None ):
23+ state = None ,
24+ ** kwargs ):
2425 """Test if function calls match.
2526
2627 This function compares a function call in the student's code with the corresponding one in the solution
@@ -42,6 +43,7 @@ def test_function(name,
4243 args_not_specified_msg (str): feedback message if the function is called but not all required arguments are specified
4344 incorrect_msg (str): feedback message if the arguments of the function in the solution doesn't match
4445 the one of the student.
46+ kwargs: named arguments which are the same as those used by ``has_equal_value``.
4547
4648 :Example:
4749
@@ -149,7 +151,8 @@ def test_function(name,
149151 test = build_test (arg_student , arg_solution ,
150152 state ,
151153 do_eval , eq_fun , msg , add_more = add_more ,
152- highlight = arg_student if highlight else None )
154+ highlight = arg_student if highlight else None ,
155+ ** kwargs )
153156 test .test ()
154157
155158 if not test .result :
@@ -172,7 +175,7 @@ def test_function(name,
172175 test = build_test (key_student , key_solution ,
173176 state ,
174177 do_eval , eq_fun , msg , add_more = add_more ,
175- highlight = key_student if highlight else None )
178+ highlight = key_student if highlight else None , ** kwargs )
176179 test .test ()
177180
178181 if not test .result :
@@ -229,7 +232,8 @@ def test_function_v2(name,
229232 incorrect_msg = None ,
230233 add_more = False ,
231234 highlight = True ,
232- state = None ):
235+ state = None ,
236+ ** kwargs ):
233237 """Test if function calls match (v2).
234238
235239 This function compares a function call in the student's code with the corresponding one in the solution
@@ -255,6 +259,7 @@ def test_function_v2(name,
255259 parameters listed in params are specified by the student.
256260 incorrect_msg (list(str)): string or list of strings (parameter-specific). Custom feedback messages if the arguments
257261 don't correspond between student and solution code.
262+ kwargs: named arguments which are the same as those used by ``has_equal_value``.
258263 """
259264
260265 rep = Reporter .active_reporter
@@ -346,7 +351,7 @@ def test_function_v2(name,
346351 sub_tests = [partial (test_call , name , call_ind , signature , params , do_eval , solution_args ,
347352 eq_fun , add_more , index ,
348353 params_not_specified_msg , params_not_matched_msg , incorrect_msg ,
349- keywords , state = state , highlight = highlight )
354+ keywords , state = state , highlight = highlight , ** kwargs )
350355 for call_ind in call_indices ]
351356 test_or (* sub_tests , state = state )
352357
@@ -360,7 +365,7 @@ def test_call(name, call_ind, signature, params, do_eval, solution_args,
360365 eq_fun , add_more , index ,
361366 params_not_specified_msg , params_not_matched_msg , incorrect_msg ,
362367 keywords , # pulled from solution process
363- state , highlight ):
368+ state , highlight , ** kwargs ):
364369 #stud_name = get_mapped_name(name, state.student_mappings)
365370
366371 rep = Reporter .active_reporter
@@ -409,15 +414,16 @@ def test_call(name, call_ind, signature, params, do_eval, solution_args,
409414 test_arg (param , do_eval [ind ],
410415 arg_student , arg_solution , param_kind , stud_name ,
411416 eq_fun , add_more ,
412- incorrect_msg [ind ], state = state , highlight = arg_student if highlight else None )
417+ incorrect_msg [ind ], state = state , highlight = arg_student if highlight else None ,
418+ ** kwargs )
413419
414420 # If all is still good, we have a winner!
415421 state .set_used (name , call_ind , index )
416422
417423def test_arg (param , do_eval ,
418424 arg_student , arg_solution , param_kind , stud_name ,
419425 eq_fun , add_more ,
420- incorrect_msg , state = None , highlight = None ):
426+ incorrect_msg , state = None , highlight = None , ** kwargs ):
421427 rep = Reporter .active_reporter
422428
423429 if incorrect_msg is None :
@@ -430,7 +436,8 @@ def test_arg(param, do_eval,
430436
431437 test = build_test (arg_student , arg_solution ,
432438 state ,
433- do_eval , eq_fun , msg , add_more = add_more , highlight = highlight )
439+ do_eval , eq_fun , msg , add_more = add_more , highlight = highlight ,
440+ ** kwargs )
434441 # TODO
435442 rep .do_test (test )
436443
@@ -447,17 +454,17 @@ def bind_args(signature, arguments, keyws):
447454 bound_args = signature .bind (* arguments , ** keyws )
448455 return (bound_args .arguments , signature .parameters )
449456
450- def build_test (stud , sol , state , do_eval , eq_fun , feedback_msg , add_more , highlight = False ):
457+ def build_test (stud , sol , state , do_eval , eq_fun , feedback_msg , add_more , highlight = False , ** kwargs ):
451458 got_error = False
452459 if do_eval :
453460
454- eval_solution , str_solution = getResultInProcess (tree = sol , process = state .solution_process )
461+ eval_solution , str_solution = getResultInProcess (tree = sol , process = state .solution_process , ** kwargs )
455462 if isinstance (str_solution , Exception ):
456463 raise ValueError ("Running an argument in the solution environment raised an error" )
457464 if isinstance (eval_solution , ReprFail ):
458465 raise ValueError ("Couldn't figure out the argument: " + eval_solution .info )
459466
460- eval_student , str_student = getResultInProcess (tree = stud , process = state .student_process )
467+ eval_student , str_student = getResultInProcess (tree = stud , process = state .student_process , ** kwargs )
461468 if isinstance (str_student , Exception ):
462469 got_error = True
463470
0 commit comments