【发布时间】:2010-12-13 20:34:23
【问题描述】:
我正在向 Django 应用程序添加一组模板标签,但我不确定如何测试它们。我已经在我的模板中使用了它们,它们似乎正在工作,但我正在寻找更正式的东西。主要逻辑在模型/模型管理器中完成并且已经过测试。标签只是检索数据并将其存储在上下文变量中,例如
{% views_for_object widget as views %}
"""
Retrieves the number of views and stores them in a context variable.
"""
# or
{% most_viewed_for_model main.model_name as viewed_models %}
"""
Retrieves the ViewTrackers for the most viewed instances of the given model.
"""
所以我的问题是你通常会测试你的模板标签吗?如果你这样做了,你会怎么做?
【问题讨论】:
标签: django django-templates django-testing