5

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?

Drafter250
  • 138
  • 9

1 Answers1

4

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.

summea
  • 7,390
  • 4
  • 32
  • 48
  • 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. – Drafter250 Jan 08 '18 at 20:54
  • @Pythonvtr250 I know what you mean about that! – summea Jan 09 '18 at 07:29