Skip to content
Myr

Merge pull request #2323 from dawran6/test-fixture

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Cleanup test_blueprint.py to use test fixtures

authored by David Lord · committed by GitHub · parents 89aaac7, c03a827 · Browse files · 1 file+10 added−18 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+10 added−18 removed

  • tests:+10 added−18 removed

1 file+10 added−18 removed

modified:tests/test_blueprints.py+10 added-18 removed
200 unmodified lines
201 with flask.Flask(__name__).test_request_context():202 assert flask.render_template('nested/nested.txt') == 'I\'m nested'203204205def test_default_static_cache_timeout():206 app = flask.Flask(__name__)207205def test_default_static_cache_timeout(app):206 class MyBlueprint(flask.Blueprint):207 def get_send_file_max_age(self, filename):208 return 100209
447 unmodified lines
657 rv = client.get('/')658 assert b'Success!' in rv.data659660663def test_context_processing():664 app = flask.Flask(__name__)661def test_context_processing(app, client):662 answer_bp = flask.Blueprint('answer_bp', __name__)663664 template_string = lambda: flask.render_template_string(665 '{% if notanswer %}{{ notanswer }} is not the answer. {% endif %}'
21 unmodified lines
687688 # Register the blueprint689 app.register_blueprint(answer_bp)690694 c = app.test_client()691 app_page_bytes = client.get('/').data692 answer_page_bytes = client.get('/bp').data693696 app_page_bytes = c.get('/').data697 answer_page_bytes = c.get('/bp').data698694 assert b'43' in app_page_bytes695 assert b'42' not in app_page_bytes696697 assert b'42' in answer_page_bytes698 assert b'43' in answer_page_bytes699700706def test_template_global():707 app = flask.Flask(__name__)701def test_template_global(app):702 bp = flask.Blueprint('bp', __name__)703704 @bp.app_template_global()705 def get_answer():
11 unmodified lines
717 with app.app_context():718 rv = flask.render_template_string('{{ get_answer() }}')719 assert rv == '42'720727def test_request_processing():728 app = flask.Flask(__name__)721def test_request_processing(app, client):722 bp = flask.Blueprint('bp', __name__)723 evts = []724 @bp.before_request725 def before_bp():
14 unmodified lines
740741 app.register_blueprint(bp)742743 assert evts == []751 rv = app.test_client().get('/bp')744 rv = client.get('/bp')745 assert rv.data == b'request|after'746 assert evts == ['before', 'after', 'teardown']747755def test_app_request_processing():756 app = flask.Flask(__name__)748def test_app_request_processing(app, client):749 bp = flask.Blueprint('bp', __name__)750 evts = []751752 @bp.before_app_first_request
21 unmodified lines
774 # before first request775 assert evts == []776777 # first request786 resp = app.test_client().get('/').data778 resp = client.get('/').data779 assert resp == b'request|after'780 assert evts == ['first', 'before', 'after', 'teardown']781782 # second request791 resp = app.test_client().get('/').data783 resp = client.get('/').data784 assert resp == b'request|after'785 assert evts == ['first'] + ['before', 'after', 'teardown'] * 2786787
25 unmodified lines