Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.

Flask extension does not load configuration lazily #1102

@youtux

Description

@youtux

I am using raven[flask]==6.2.1 and it appears that the flask extension loads the configuration as soon as possible, rather than using lazy evaluation as Flask recommends.
This behavior results in no exception being forwarded to sentry, since my project needs to load the configuration after the application has been created.

I attach a snippet that replicates the issue.

import mock
import pytest

import flask
from raven.contrib.flask import Sentry

@mock.patch('raven.base.Client.send', autospect=True, return_value=None)
def test_lazy_configuration(m):
    app = flask.Flask(__name__)
    @app.route('/')
    def index():
        raise ValueError('Error here')

    app.sentry = Sentry(app)
    app.config['SENTRY_CONFIG'] = {
        'dsn': 'https://user:[email protected]/44',
    }

    response = app.test_client().get('/')
    m.assert_called_once()

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions