File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -61,15 +61,17 @@ def _push_appctx(*args, **kwargs):
6161 if hub .get_integration (FlaskIntegration ) is not None :
6262 # always want to push scope regardless of whether WSGI app might already
6363 # have (not the case for CLI for example)
64- hub .push_scope ()
64+ scope_manager = hub .push_scope ()
65+ scope_manager .__enter__ ()
66+ _app_ctx_stack .top .sentry_sdk_scope_manager = scope_manager
6567 with hub .configure_scope () as scope :
6668 scope ._name = "flask"
6769
6870
6971def _pop_appctx (* args , ** kwargs ):
70- hub = Hub . current
71- if hub . get_integration ( FlaskIntegration ) is not None :
72- hub . pop_scope_unsafe ( )
72+ scope_manager = getattr ( _app_ctx_stack . top , "sentry_sdk_scope_manager" , None )
73+ if scope_manager is not None :
74+ scope_manager . __exit__ ( None , None , None )
7375
7476
7577def _request_started (sender , ** kwargs ):
Original file line number Diff line number Diff line change @@ -495,3 +495,15 @@ def generate():
495495
496496 with configure_scope () as scope :
497497 assert not scope ._tags ["request_data" ]
498+
499+
500+ def test_scoped_test_client (sentry_init , app ):
501+ sentry_init (integrations = [flask_sentry .FlaskIntegration ()])
502+
503+ @app .route ("/" )
504+ def index ():
505+ return "ok"
506+
507+ with app .test_client () as client :
508+ response = client .get ("/" )
509+ assert response .status_code == 200
You can’t perform that action at this time.
0 commit comments