我具有要在此处创建参数化夹具的功能
def make_execution_objects(self, params: dict) -> Iterable:
for action in self.get_all_actions():
exe_object = {'action': action['ref']}
exe_params = self._extract_params(action, params)
if exe_params:
exe_object["parameters"] = exe_params
yield exe_object
然后我的conftest.py文件中就有2个固定的
@pytest.fixture()
def actions(st2_tester, marged_json):
return tuple(st2_tester.make_execution_objects(marged_json))
@pytest.fixture(params=actions)
def exe_params(request):
return request.param
但是由于某些原因,我在TypeError: 'function' object is not iterable
行中获得了params=actions
。
我还尝试不返回tuple(st2_tester.make_execution_objects(marged_json))
,而只返回st2_tester.make_execution_objects(marged_json)
,但仍然返回