7π
β
So as @e4c5 noted itβs the same assertTemplateUsed
.
Just tested it:
app/views.py
from django.shortcuts import render_to_response
def base_index(request):
return render_to_response('base.html')
def template_index(request):
return render_to_response('template.html')
app/urls.py
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^base$', views.base_index, name='base'),
url(r'^template$', views.template_index, name='template')
]
templates/template.html
{% extends 'base.html' %}
{% block content %}
<div>help</div>
{% endblock %}
app/tests.py
from django.test import TestCase
class TemplateTest(TestCase):
def test_base_view(self):
response = self.client.get('/base')
self.assertTemplateUsed(response, 'base.html')
self.assertTemplateNotUsed(response, 'template.html')
def test_template_view(self):
response = self.client.get('/template')
self.assertTemplateUsed(response, 'template.html')
self.assertTemplateUsed(response, 'base.html')
All 2 tests passed
π€vishes_shell
Source:stackexchange.com