Skip to content

Support different fixtures for scopes #77

@tschm

Description

@tschm

The tmp_path fixture has scope "function". Hence your copie fixture will always have the same scope which makes it less useful than it could be.

I have worked first on a fixture for creating a temp_path (for dst) that has a larger scope, e.g

@pytest.fixture(scope="session")
def copier_dst(tmp_path_factory):
    target = tmp_path_factory.mktemp("copier")
    LOGGER.info(target)
    return target

and then doing the expensive construction of the template only once for all tests...

@pytest.fixture(scope="module")
def result(src_path, copier_dst):
    run_copy(
        src_path=src_path,
        dst_path=copier_dst,
        unsafe=True,
        defaults=True,
        user_defaults={"project_name": "maffay"},
    )

    os.chdir(copier_dst)

    # fire off poetry
    os.system("poetry update -vv")
    # yield the folder
    yield copier_dst
    # the path is deleted at the very end when all tests have finished
    shutil.rmtree(copier_dst)

I am now exposing the built template and can run various tests against it.

What do you think? Please share your thoughts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions