Ответ 1
Вот как я это делаю (извлечен из мой django-multiforloop):
from django.test import TestCase
from django.template import Context, Template
class TagTests(TestCase):
def tag_test(self, template, context, output):
t = Template('{% load multifor %}'+template)
c = Context(context)
self.assertEqual(t.render(c), output)
def test_for_tag_multi(self):
template = "{% for x in x_list; y in y_list %}{{ x }}:{{ y }}/{% endfor %}"
context = {"x_list": ('one', 1, 'carrot'), "y_list": ('two', 2, 'orange')}
output = u"one:two/1:2/carrot:orange/"
self.tag_test(template, context, output)
Это довольно похоже на то, как тесты изложены в Django собственный набор тестов, но не полагаясь на django несколько сложное тестовое оборудование.