atst/tests/utils.py
Patrick Smith ba97117a74 Add tests for portfolio funding route
This adds a helper to grab a template's context. Using a helper from the
Flask documentation: http://flask.pocoo.org/docs/1.0/signals/?highlight=template_rendered#subscribing-to-signals
2019-01-15 21:10:59 -05:00

17 lines
376 B
Python

from flask import template_rendered
from contextlib import contextmanager
@contextmanager
def captured_templates(app):
recorded = []
def record(sender, template, context, **extra):
recorded.append((template, context))
template_rendered.connect(record, app)
try:
yield recorded
finally:
template_rendered.disconnect(record, app)