Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Quart 0.19 onwards #2403

Merged
merged 9 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

Check warning on line 56 in sentry_sdk/integrations/quart.py

View check run for this annotation

Codecov / codecov/patch

sentry_sdk/integrations/quart.py#L53-L56

Added lines #L53 - L56 were not covered by tests

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
Loading