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):
61
61
if hub .get_integration (FlaskIntegration ) is not None :
62
62
# always want to push scope regardless of whether WSGI app might already
63
63
# 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
65
67
with hub .configure_scope () as scope :
66
68
scope ._name = "flask"
67
69
68
70
69
71
def _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 )
73
75
74
76
75
77
def _request_started (sender , ** kwargs ):
Original file line number Diff line number Diff line change @@ -495,3 +495,15 @@ def generate():
495
495
496
496
with configure_scope () as scope :
497
497
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