Esempio n. 1
0
def fake_project_cli(
    fake_repo_path: Path, dummy_config: Path, fake_kedro_cli: click.CommandCollection
):
    old_settings = settings.as_dict()
    starter_path = Path(__file__).parents[3].resolve()
    starter_path = starter_path / "features" / "steps" / "test_starter"
    CliRunner().invoke(
        fake_kedro_cli, ["new", "-c", str(dummy_config), "--starter", str(starter_path)]
    )

    # NOTE: Here we load a couple of modules, as they would be imported in
    # the code and tests.
    # It's safe to remove the new entries from path due to the python
    # module caching mechanism. Any `reload` on it will not work though.
    old_path = sys.path.copy()
    sys.path = [str(fake_repo_path / "src")] + sys.path

    import_module(PACKAGE_NAME)
    configure_project(PACKAGE_NAME)
    yield fake_kedro_cli

    # reset side-effects of configure_project
    pipelines._clear(PACKAGE_NAME)  # this resets pipelines loading state
    for key, value in old_settings.items():
        settings.set(key, value)
    sys.path = old_path
    del sys.modules[PACKAGE_NAME]
Esempio n. 2
0
def dummy_context(
    tmp_path, prepare_project_dir, env, extra_params, mocker
):  # pylint: disable=unused-argument
    configure_project(MOCK_PACKAGE_NAME)
    context = KedroContext(
        MOCK_PACKAGE_NAME, str(tmp_path), env=env, extra_params=extra_params
    )

    yield context
    pipelines._clear(MOCK_PACKAGE_NAME)
Esempio n. 3
0
def dummy_context(tmp_path, prepare_project_dir, env, extra_params, mocker):  # pylint: disable=unused-argument
    mocker.patch("kedro.framework.project._validate_module")
    configure_project(MOCK_PACKAGE_NAME)
    context = KedroContext(MOCK_PACKAGE_NAME,
                           str(tmp_path),
                           env=env,
                           extra_params=extra_params)

    yield context
    pipelines._clear(MOCK_PACKAGE_NAME)