Pytest-cookies

Latest version: v0.7.0

Safety actively analyzes 682487 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 2 of 2

0.3.0

Add capability to specify the template directory via ``bake()``.

python
pytest.fixture
def custom_template():
return "templates/minimal/"


def test_bake_custom_project(cookies, custom_template):
"""Test for generating a new project."""
result = cookies.bake(template=custom_template)

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


Please see the [documentation](https://github.com/hackebrot/pytest-cookies#specify-template-directory) for more information.

0.2.0

Upgrade to [Cookiecutter Shortbread](https://github.com/audreyr/cookiecutter/releases/tag/1.4.0) which fixed user config based `replay_dir` and `cookiecutters_dir`.

0.1.0

cookies.bake()

[pytest](https://github.com/pytest-dev/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](https://github.com/audreyr/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`:

python
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](http://cookiecutter.readthedocs.org/en/latest/advanced_usage.html#injecting-extra-context) section of the
official cookiecutter documentation.

Page 2 of 2

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.