cookiecutter-django - Cookiecutter 模板测试,cookies.bake 是什么?

标签 cookiecutter-django

我想弄清楚如何为我的 cookiecutter 模板编写测试套件。

查看 cookiecutter-django/tests/test_cookiecutter_generation.py 中 cookiecutter-django 模板的测试后我看到大多数测试函数都带有一个名为 cookies 的参数。 .在测试函数本身中,对作为cookie 参数传入的任何对象都有一个方法调用,该参数称为bake .

我想知道这个对象是什么以及它是从哪里导入的?

最佳答案

在这种情况下,cookies似乎是 fixturepytest-cookies 中定义,如相关pytest_cookies.py source code所示.
cookies夹具实际上似乎是 a wrapper for cookiecutter本身。此外,相关的 cookies.bake()方法可用于generate a project根据您提供的 cookiecutter模板。

值得注意的是pytest-cookiespytest 的插件,因此,此插件在测试期间可作为相关 pytest documentation indicates 访问。 :

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



因此,因为 requirements指定 pytest-cookiescookiecutter-django 一起使用, cookies固定装置来自 pytest-cookies在测试期间应该自动可用。

关于cookiecutter-django - Cookiecutter 模板测试,cookies.bake 是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48108328/

相关文章:

python - 无法将变量从应用程序中的另一个模板传递给 Django 主页模板

python - 重新启动后的Django docker-compose需要再次迁移

python - 使用 docker 的 cookiecutter-django 本地开发

docker - Pip 编译为 dockerfile 的一部分 - 向requirements.txt 添加新条目的最快方法?

python - Django 脆皮表单 - 在 home.html 中创建表单并收到错误

python - 打包 Django 项目的推荐方式?具有多个应用程序或多个 Django 包的 Django 包?

django - 是否有使用 cookiecutter-django 创建应用程序的命令?

带有 docker-compose 的 Django 应用程序将数据保存在媒体卷中

postgresql - 配置 PyCharm 以使用 docker-compose