#NEWLINE# def assertTemplateUsed( self , response = None , template_name = None , msg_prefix = '' ) : #NEWLINE# #INDENT# '\n        Asserts that the template with the provided name was used in rendering\n        the response. Also usable as context manager.\n        ' #NEWLINE# if ( ( response is None ) and ( template_name is None ) ) : #NEWLINE# #INDENT# raise TypeError ( 'response and/or template_name argument must be provided' ) #NEWLINE# #UNINDENT# if msg_prefix : #NEWLINE# #INDENT# msg_prefix += ': ' #NEWLINE# #UNINDENT# if ( ( not hasattr ( response , 'templates' ) ) or ( ( response is None ) and template_name ) ) : #NEWLINE# #INDENT# if response : #NEWLINE# #INDENT# template_name = response #NEWLINE# response = None #NEWLINE# #UNINDENT# context = _AssertTemplateUsedContext ( self , template_name ) #NEWLINE# return context #NEWLINE# #UNINDENT# template_names = [ t . name for t in response . templates ] #NEWLINE# if ( not template_names ) : #NEWLINE# #INDENT# self . fail ( ( msg_prefix + 'No templates used to render the response' ) ) #NEWLINE# #UNINDENT# self . assertTrue ( ( template_name in template_names ) , ( msg_prefix + ( "Template '%s' was not a template used to render the response. Actual template(s) used: %s" % ( template_name , ', ' . join ( template_names ) ) ) ) )