Skip to content

0.1.0

Compare
Choose a tag to compare
@hackebrot hackebrot released this 22 Oct 22:48
· 200 commits to main since this release

cookies.bake()

pytest is a mature full-featured Python testing tool that provides easy
no boilerplate testing. Its hook-baesd customization system supports integration
of external plugins such as pytest-cookies.

This plugin comes with a cookies fixture which is a wrapper for the
cookiecutter API for generating projects. It helps you verify that your
template is working as expected and takes care of cleaning up after running the
tests.

Usage

The cookies.bake() method generates a new project from your template based on the
default values specified in cookiecutter.json:

def test_bake_project(cookies):
    result = cookies.bake(extra_context={'repo_name': 'helloworld'})

    assert result.exit_code == 0
    assert result.exception is None
    assert result.project.basename == 'helloworld'
    assert result.project.isdir()

It accepts the extra_context keyword argument that will be
passed to cookiecutter. The given dictionary will override the default values
of the template context, allowing you to test arbitrary user input data.

Please see the Injecting Extra Context section of the
official cookiecutter documentation.