Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix config scope and tmp dir creation #90

Open
wants to merge 3 commits into
base: copie-session
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions pytest_copie/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import pytest
import yaml
from _pytest.tmpdir import TempPathFactory
from copier import run_copy


Expand Down Expand Up @@ -105,7 +106,7 @@ def copy(self, extra_answers: dict = {}, template_dir: Optional[Path] = None) ->
return Result(exception=e, exit_code=-1)


@pytest.fixture
@pytest.fixture(scope="session")
def _copier_config_file(tmp_path_factory) -> Path:
"""Return a temporary copier config file."""
# create a user from the tmp_path_factory fixture
Expand Down Expand Up @@ -150,7 +151,9 @@ def copie(request, tmp_path: Path, _copier_config_file: Path) -> Generator:


@pytest.fixture(scope="session")
def copie_session(request, tmp_path_factory: Path, _copier_config_file: Path) -> Generator:
def copie_session(
request, tmp_path_factory: TempPathFactory, _copier_config_file: Path
) -> Generator:
"""Yield an instance of the :py:class:`Copie <pytest_copie.plugin.Copie>` helper class.

The class can then be used to generate a project from a template.
Expand All @@ -167,7 +170,7 @@ def copie_session(request, tmp_path_factory: Path, _copier_config_file: Path) ->
template_dir = Path(request.config.option.template)

# set up a test directory in the tmp folder
(test_dir := tmp_path_factory / "copie").mkdir()
test_dir = tmp_path_factory.mktemp("copie")

yield Copie(template_dir, test_dir, _copier_config_file)

Expand Down