File: getting_started.md

package info (click to toggle)
pytest-cookies 0.7.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 164 kB
  • sloc: python: 305; makefile: 33
file content (38 lines) | stat: -rw-r--r-- 1,255 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Installation

**pytest-cookies** is available for download from [PyPI] via [pip]:

```no-highlight
$ pip install pytest-cookies
```

It will automatically install [pytest] along with [cookiecutter].

  [PyPI]: https://pypi.python.org/pypi
  [cookiecutter]: https://github.com/cookiecutter/cookiecutter
  [pip]: https://pypi.python.org/pypi/pip/
  [pytest]: https://github.com/pytest-dev/pytest

# 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] section of the
official cookiecutter documentation.

  [Injecting Extra Context]: https://cookiecutter.readthedocs.io/en/latest/advanced/injecting_context.html#injecting-extra-context