'Asserts that the template with the provided name was used in rendering
the response. Also usable as context manager.'

def assertTemplateUsed(self, response=None, template_name=None, msg_prefix=u''):

    if ((response is None) and (template_name is None)):
        raise TypeError(u'response    and/or    template_name    argument    must    be    provided')
    if msg_prefix:
        msg_prefix += u':    '
    if ((not hasattr(response, u'templates')) or ((response is None) and template_name)):
        if response:
            template_name = response
            response = None
        context = _AssertTemplateUsedContext(self, template_name)
        return context
    template_names = [t.name for t in response.templates]
    if (not template_names):
        self.fail((msg_prefix + u'No    templates    used    to    render    the    response'))
    self.assertTrue((template_name in template_names), (msg_prefix + (u"Template    '%s'    was    not    a    template    used    to    render    the    response.    Actual    template(s)    used:    %s" % (template_name, u',    '.join(template_names)))))
