Cookiecutter template testing, what is cookies.bake?
Asked Answered
D

1

6

I am Trying to figure out how to write a test suite for my cookiecutter template.

after looking at the tests for the cookiecutter-django template in cookiecutter-django/tests/test_cookiecutter_generation.py I see that most of the test functions take a parameter called cookies. Within the test functions themselves there is a method call on whatever object is being passed in as the cookies parameter that is called bake.

I would like to know what this object is and where it's imported from?

Dingle answered 5/1, 2018 at 6:29 Comment(0)
F
5

In this case, cookies appears to be a fixture that is defined in pytest-cookies, as shown in the related pytest_cookies.py source code.

The cookies fixture actually appears to be a wrapper for cookiecutter itself. Additionally, the related cookies.bake() method can be used to generate a project based on your given cookiecutter template.

It may be interesting to note that pytest-cookies is a plugin for pytest, and as such, this plugin is accessible during testing as the related pytest documentation indicates:

If a plugin is installed, pytest automatically finds and integrates it, there is no need to activate it.

Thus, because the requirements specify that pytest-cookies is to be used with cookiecutter-django, the cookies fixture from pytest-cookies should automatically be available during testing.

Fidler answered 5/1, 2018 at 7:37 Comment(2)
OK That clears it up! I did not realize that the pytest plugin automatically provided the fixture to the namespace. I was looking for a specific import.Dingle
@Pythonvtr250 I know what you mean about that!Fidler

© 2022 - 2024 — McMap. All rights reserved.