Browse Source

fix test_signals

pull/1509/head
Alexander Pantyukhin 10 years ago committed by Markus Unterwaditzer
parent
commit
e57199e0c4
  1. 10
      tests/test_signals.py

10
tests/test_signals.py

@ -59,13 +59,16 @@ def test_before_render_template():
context['whiskey'] = 43 context['whiskey'] = 43
recorded.append((template, context)) recorded.append((template, context))
with flask.before_render_template.connected_to(record): flask.before_render_template.connect(record, app)
try:
rv = app.test_client().get('/') rv = app.test_client().get('/')
assert len(recorded) == 1 assert len(recorded) == 1
template, context = recorded[0] template, context = recorded[0]
assert template.name == 'simple_template.html' assert template.name == 'simple_template.html'
assert context['whiskey'] == 43 assert context['whiskey'] == 43
assert rv.data == b'<h1>43</h1>' assert rv.data == b'<h1>43</h1>'
finally:
flask.before_render_template.disconnect(record, app)
def test_before_render_template_signal_not_None_result_render_skip_render_template(): def test_before_render_template_signal_not_None_result_render_skip_render_template():
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -80,9 +83,12 @@ def test_before_render_template_signal_not_None_result_render_skip_render_templa
recorded.append((template, context)) recorded.append((template, context))
return 'Not template string' return 'Not template string'
with flask.before_render_template.connected_to(record): flask.before_render_template.connect(record, app)
try:
rv = app.test_client().get('/') rv = app.test_client().get('/')
assert rv.data == 'Not template string' assert rv.data == 'Not template string'
finally:
flask.before_render_template.disconnect(record, app)
def test_request_signals(): def test_request_signals():
app = flask.Flask(__name__) app = flask.Flask(__name__)

Loading…
Cancel
Save