Skip to content

Commit

Permalink
Support Quart 0.19 onwards (getsentry#2403)
Browse files Browse the repository at this point in the history
* Support Quart 0.19 onwards

Quart 0.19 is based on Flask and hence no longer has a Scaffold class,
instead Flask's should be used.

---------

Co-authored-by: Ivana Kellyerova <[email protected]>
  • Loading branch information
pgjones and sentrivana authored Oct 13, 2023
1 parent 0452535 commit 6906dad
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
7 changes: 6 additions & 1 deletion sentry_sdk/integrations/quart.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
request,
websocket,
)
from quart.scaffold import Scaffold # type: ignore
from quart.signals import ( # type: ignore
got_background_exception,
got_request_exception,
Expand All @@ -49,6 +48,12 @@
from quart.utils import is_coroutine_function # type: ignore
except ImportError:
raise DidNotEnable("Quart is not installed")
else:
# Quart 0.19 is based on Flask and hence no longer has a Scaffold
try:
from quart.scaffold import Scaffold # type: ignore
except ImportError:
from flask.sansio.scaffold import Scaffold # type: ignore

TRANSACTION_STYLE_VALUES = ("endpoint", "url")

Expand Down
17 changes: 2 additions & 15 deletions tests/integrations/quart/test_quart.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
@pytest_asyncio.fixture
async def app():
app = Quart(__name__)
app.debug = True
app.config["TESTING"] = True
app.debug = False
app.config["TESTING"] = False
app.secret_key = "haha"

auth_manager.init_app(app)
Expand Down Expand Up @@ -123,22 +123,15 @@ async def test_transaction_style(


@pytest.mark.asyncio
@pytest.mark.parametrize("debug", (True, False))
@pytest.mark.parametrize("testing", (True, False))
async def test_errors(
sentry_init,
capture_exceptions,
capture_events,
app,
debug,
testing,
integration_enabled_params,
):
sentry_init(debug=True, **integration_enabled_params)

app.debug = debug
app.testing = testing

@app.route("/")
async def index():
1 / 0
Expand Down Expand Up @@ -323,9 +316,6 @@ def foo():
async def test_500(sentry_init, capture_events, app):
sentry_init(integrations=[quart_sentry.QuartIntegration()])

app.debug = False
app.testing = False

@app.route("/")
async def index():
1 / 0
Expand All @@ -349,9 +339,6 @@ async def error_handler(err):
async def test_error_in_errorhandler(sentry_init, capture_events, app):
sentry_init(integrations=[quart_sentry.QuartIntegration()])

app.debug = False
app.testing = False

@app.route("/")
async def index():
raise ValueError()
Expand Down
8 changes: 6 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ envlist =

# Quart
{py3.7,py3.8,py3.9,py3.10,py3.11}-quart-v{0.16,0.17,0.18}
{py3.8,py3.9,py3.10,py3.11}-quart-v{0.19}

# Redis
{py2.7,py3.7,py3.8,py3.9,py3.10,py3.11}-redis
Expand Down Expand Up @@ -403,14 +404,17 @@ deps =
# Quart
quart: quart-auth
quart: pytest-asyncio
quart: werkzeug<3.0.0
quart-v0.16: blinker<1.6
quart-v0.16: jinja2<3.1.0
quart-v0.16: Werkzeug<2.1.0
quart-v0.17: blinker<1.6
quart-v0.16: quart>=0.16.1,<0.17.0
quart-v0.17: Werkzeug<3.0.0
quart-v0.17: blinker<1.6
quart-v0.17: quart>=0.17.0,<0.18.0
quart-v0.18: Werkzeug<3.0.0
quart-v0.18: quart>=0.18.0,<0.19.0
quart-v0.19: Werkzeug>=3.0.0
quart-v0.19: quart>=0.19.0,<0.20.0

# Requests
requests: requests>=2.0
Expand Down

0 comments on commit 6906dad

Please sign in to comment.