错误:尝试构建参数化夹具时“函数”对象不可迭代

时间:2020-02-02 14:08:02

标签: python pytest

我具有要在此处创建参数化夹具的功能

 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),但仍然返回

0 个答案:

没有答案
相关问题