Skip to content

Commit

Permalink
Merge pull request #63 from jamesmyatt/bugfix/62
Browse files Browse the repository at this point in the history
Fixes for cookiecutter 2.1.0, especially PyYAML
  • Loading branch information
hackebrot authored Mar 21, 2023
2 parents 2973e67 + e477c11 commit a2c354a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/run-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,19 @@ jobs:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
environment: ["py36", "py37", "py38", "py39", "flake8"]
environment: ["py37", "py38", "py39", "py310", "py311", "flake8"]

include:
- environment: "py36"
python: "3.6"
- environment: "py37"
python: "3.7"
- environment: "py38"
python: "3.8"
- environment: "py39"
python: "3.9"
- environment: "py310"
python: "3.10"
- environment: "py311"
python: "3.11"
- environment: "flake8"
python: "3.7"

Expand Down
11 changes: 6 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def read(fname):

setuptools.setup(
name="pytest-cookies",
version="0.6.1",
version="0.7.0",
author="Raphael Pierzina",
author_email="raphael@hackebrot.de",
maintainer="Raphael Pierzina",
Expand All @@ -31,21 +31,22 @@ def read(fname):
package_dir={"": "src"},
include_package_data=True,
zip_safe=False,
python_requires=">=3.6",
python_requires=">=3.7",
install_requires=[
"cookiecutter>=1.4.0",
"pytest>=3.3.0",
"cookiecutter>=2.1.0", # uses pyyaml
"pytest>=3.9.0", # adds tmp_path fixtures
],
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python",
"Topic :: Software Development :: Testing",
Expand Down
21 changes: 9 additions & 12 deletions src/pytest_cookies/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@

import py
import pytest
import yaml

from cookiecutter.generate import generate_context
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 +119,16 @@ 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")
with config_file.open("w", encoding="utf-8") as f:
yaml.dump(config, f, Dumper=yaml.Dumper)

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


Expand Down
6 changes: 3 additions & 3 deletions tests/test_user_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def test_config(testdir):
"""
# -*- coding: utf-8 -*-
import poyo
import yaml
def test_user_dir(tmpdir_factory, _cookiecutter_config_file):
Expand All @@ -24,8 +24,8 @@ def test_user_dir(tmpdir_factory, _cookiecutter_config_file):
def test_valid_cookiecutter_config(_cookiecutter_config_file):
config_text = _cookiecutter_config_file.read()
config = poyo.parse_string(config_text)
with open(_cookiecutter_config_file) as f:
config = yaml.load(f, Loader=yaml.Loader)
user_dir = _cookiecutter_config_file.dirpath()
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[tox]
envlist = py{36,37,38,39}-pytest{3,4,5,6},flake8
envlist = py{37,38,39,310,311}-pytest{4,5,6,7},flake8

[testenv]
deps =
pytest3: pytest>=3,<4
pytest4: pytest>=4,<5
pytest5: pytest>=5,<6
pytest6: pytest>=6,<7
pytest7: pytest>=7,<8
commands = pytest {posargs:tests}

[testenv:flake8]
Expand Down

0 comments on commit a2c354a

Please sign in to comment.