def test_extension_use_the_application_bound_to_the_current_context(app, mail): mailer = Mailer() mailer.init_app(app) with app.test_request_context(): mailer.send(mail) assert mailer.outbox == [mail,]
def test_extension_raises_error_if_no_application_bound_to_context(app, mail): mailer = Mailer() mailer.init_app(app) with pytest.raises(RuntimeError) as exc: mailer.send(mail) assert 'no application bound to current context' in exc.exconly()