如何在测试中将yield语句移动到单独的方法中?

时间:2018-04-23 18:02:34

标签: python python-3.x

我有以下装置:

@pytest.fixture
async def service(checker_config):
    alert_model_path = 'components.checker.service.AlertModel'
    ...
    with mock.patch(alert_model_path, AlertModelDev):
          yield CheckerService(checker_config)

如何将方法service的主体移动到单独的方法中?

我试过了:

@contextmanager
def mock_models(checker_config):
    alert_model_path = 'components.checker.service.AlertModel'
    ...
    with mock.patch(alert_model_path, AlertModelDev):
            yield CheckerService(checker_config)

@pytest.fixture
async def service(checker_config):
    with mock_models(checker_config):
         yeild

但它不起作用。我做错了什么?

0 个答案:

没有答案