|
|
|
@ -46,6 +46,30 @@ def test_template_rendered():
|
|
|
|
|
finally: |
|
|
|
|
flask.template_rendered.disconnect(record, app) |
|
|
|
|
|
|
|
|
|
def test_before_render_template(): |
|
|
|
|
app = flask.Flask(__name__) |
|
|
|
|
|
|
|
|
|
@app.route('/') |
|
|
|
|
def index(): |
|
|
|
|
return flask.render_template('simple_template.html', whiskey=42) |
|
|
|
|
|
|
|
|
|
recorded = [] |
|
|
|
|
|
|
|
|
|
def record(sender, template, context): |
|
|
|
|
context['whiskey'] = 43 |
|
|
|
|
recorded.append((template, context)) |
|
|
|
|
|
|
|
|
|
flask.before_render_template.connect(record, app) |
|
|
|
|
try: |
|
|
|
|
rv = app.test_client().get('/') |
|
|
|
|
assert len(recorded) == 1 |
|
|
|
|
template, context = recorded[0] |
|
|
|
|
assert template.name == 'simple_template.html' |
|
|
|
|
assert context['whiskey'] == 43 |
|
|
|
|
assert rv.data == b'<h1>43</h1>' |
|
|
|
|
finally: |
|
|
|
|
flask.before_render_template.disconnect(record, app) |
|
|
|
|
|
|
|
|
|
def test_request_signals(): |
|
|
|
|
app = flask.Flask(__name__) |
|
|
|
|
calls = [] |
|
|
|
|