如何在 Python 中将函数作为参数传递?我想做一些类似下面的代码的事情。
我的目标是传递不同的参数来测试单个函数。
def __internal_function(inputs):
a,b,c,d = inputs
new_value_of_b = copy.deepcopy(b)
name = b['name']
age = b['age']
weight = b['weight']
height = b['height']
new_value_of_b2 = [name, age, weight, height]
new_value_of_b3= new_value_of_b['weight']['unit'] = 'cm'
del new_value_of_b['age']
return new_value_of_b,new_value_of_b2,new_value_of_b3
@pytest.mark.parametrize('values',__internal_function,'expected_code',[100,200,300])
assert func(__internal_function)== expected_code