8000 test: Add new test for Flask errorhandling · etherscan-io/sentry-python@3e7070b · GitHub
[go: up one dir, main page]

Skip to content

Commit 3e7070b

Browse files
committed
test: Add new test for Flask errorhandling
1 parent a0d8d71 commit 3e7070b

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/integrations/flask/test_flask.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,3 +507,28 @@ def index():
507507
with app.test_client() as client:
508508
response = client.get("/")
509509
assert response.status_code == 200
510+
511+
512+
@pytest.mark.parametrize("exc_cls", [ZeroDivisionError, Exception])
513+
def test_errorhandler_for_exception_swallows_exception(
514+
sentry_init, app, capture_events, exc_cls
515+
):
516+
# In contrast to error handlers for a status code, error
517+
# handlers for exceptions can swallow the exception (this is
518+
# just how the Flask signal works)
519+
sentry_init(integrations=[flask_sentry.FlaskIntegration()])
520+
events = capture_events()
521+
522+
@app.route("/")
523+
def index():
524+
1 / 0
525+
526+
@app.errorhandler(exc_cls)
527+
def zerodivision(e):
528+
return "ok"
529+
530+
with app.test_client() as client:
531+
response = client.get("/")
532+
assert response.status_code == 200
533+
534+
assert not events

0 commit comments

Comments
 (0)
0