How to test custom template tags in Django?

Posted by Mark Lavin on Stack Overflow See other posts from Stack Overflow or by Mark Lavin
Published on 2009-11-06T14:11:26Z Indexed on 2010/05/06 5:48 UTC
Read the original article Hit count: 404

I'm adding a set of template tags to a Django application and I'm not sure how to test them. I've used them in my templates and they seem to be working but I was looking for something more formal. The main logic is done in the models/model managers and has been tested. The tags simply retrieve data and store it in a context variable such as

{% 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.
"""

So my question is do you typically test your template tags and if you do how do you do it?

© Stack Overflow or respective owner

Related posts about django

Related posts about django-template-tags