1 | from django.template.loader import get_template
|
---|
2 | from django.test import TestCase
|
---|
3 | from django.test.signals import template_rendered
|
---|
4 |
|
---|
5 |
|
---|
6 | class TestTemplateInheritance(TestCase):
|
---|
7 | def test_inherit_template(self):
|
---|
8 | self.template_rendered = False
|
---|
9 | def signal_receiver(template, context, **kwargs):
|
---|
10 | if template.name == 'base.html':
|
---|
11 | self.template_rendered = True
|
---|
12 |
|
---|
13 | template_rendered.connect(signal_receiver)
|
---|
14 |
|
---|
15 | template = get_template('derived.html')
|
---|
16 | template.render()
|
---|
17 |
|
---|
18 | self.assertTrue(self.template_rendered)
|
---|