Skip to content

Commit

Permalink
Fix #62
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmyatt authored Jul 4, 2022
1 parent 2973e67 commit a5d414e
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/pytest_cookies/plugin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-

import json
import os
import pathlib
import warnings
Expand All @@ -10,11 +11,6 @@
from cookiecutter.main import cookiecutter
from cookiecutter.prompt import prompt_for_config

USER_CONFIG = u"""
cookiecutters_dir: "{cookiecutters_dir}"
replay_dir: "{replay_dir}"
"""


class Result(object):
"""Holds the captured result of the cookiecutter project generation."""
Expand Down Expand Up @@ -122,16 +118,17 @@ def bake(self, extra_context=None, template=None):
@pytest.fixture(scope="session")
def _cookiecutter_config_file(tmpdir_factory):
user_dir = tmpdir_factory.mktemp("user_dir")
config_file = user_dir.join("config")

cookiecutters_dir = user_dir.mkdir("cookiecutters")
replay_dir = user_dir.mkdir("cookiecutter_replay")
config = {
"cookiecutters_dir": str(user_dir.mkdir("cookiecutters")),
"replay_dir": str(user_dir.mkdir("cookiecutter_replay")),
}

config_text = USER_CONFIG.format(
cookiecutters_dir=cookiecutters_dir, replay_dir=replay_dir
)
config_file = user_dir.join("config")
# Note that the file is expected to be YAML, but JSON is a subset of YAML
with config_file.open("w", encoding="utf-8") as f:
json.dump(config, f, indent=2)

config_file.write_text(config_text, encoding="utf8")
return config_file


Expand Down

0 comments on commit a5d414e

Please sign in to comment.