@pytest.fixture(autouse=True, scope='session')
def instrument_jinja():
 import jinja2
 old_render = jinja2.Template.render
 def instrumented_render(self, *args, **kwargs):
  context = dict(*args, **kwargs)
  test.signals.template_rendered.send(sender=self, template=self, context=context)
  return old_render(self, *args, **kwargs)
 jinja2.Template.render = instrumented_render

@ pytest . fixture ( autouse = True , scope = 'session' ) def instrument_jinja ( ) : import jinja2 old_render = jinja2 . Template . render def instrumented_render ( self , * args , ** kwargs ) : context = dict ( * args , ** kwargs ) test . signals . template_rendered . send ( sender = self , template = self , context = context ) return old_render ( self , * args , ** kwargs ) jinja2 . Template . render = instrumented_render
make sure the "templates" list in a response is properly updated .