@@ -27,31 +27,19 @@ def hookwrapper(itemgetter, **kwargs):
2727    """ 
2828
2929    @wrapt .decorator  
30-     def  _with_scope (wrapped , instance , args , kwargs ):
30+     def  _with_isolation_scope (wrapped , instance , args , kwargs ):
3131        item  =  itemgetter (* args , ** kwargs )
32-         scope  =  _resolve_scope_marker_value (item .get_closest_marker ("sentry_client" ))
32+         isolation_scope  =  _resolve_scope_marker_value (item .get_closest_marker ("sentry_client" ))
3333
34-         if  scope .client .get_integration (PytestIntegration ) is  None :
34+         if  isolation_scope .client .get_integration (PytestIntegration ) is  None :
3535            yield 
3636        else :
37-             with  sentry_sdk .use_scope ( scope ):
37+             with  sentry_sdk .use_isolation_scope ( isolation_scope ):
3838                gen  =  wrapped (* args , ** kwargs )
39- 
40-             while  True :
41-                 try :
42-                     with  sentry_sdk .use_scope (scope ):
43-                         chunk  =  next (gen )
44- 
45-                     y  =  yield  chunk 
46- 
47-                     with  sentry_sdk .use_scope (scope ):
48-                         gen .send (y )
49- 
50-                 except  StopIteration :
51-                     break 
39+                 yield  from  gen 
5240
5341    def  inner (f ):
54-         return  pytest .hookimpl (hookwrapper = True , ** kwargs )(_with_scope (f ))
42+         return  pytest .hookimpl (hookwrapper = True , ** kwargs )(_with_isolation_scope (f ))
5543
5644    return  inner 
5745
@@ -89,7 +77,7 @@ def pytest_runtest_call(item):
8977
9078    # We use the full name including parameters because then we can identify 
9179    # how often a single test has run as part of the same GITHUB_RUN_ID. 
92-     with  sentry_sdk .continue_trace (dict (sentry_sdk .get_current_scope ().iter_trace_propagation_headers ())):
80+     with  sentry_sdk .continue_trace (dict (sentry_sdk .get_isolation_scope ().iter_trace_propagation_headers ())):
9381        with  sentry_sdk .start_span (op = op , name = name ) as  span :
9482            span .set_attribute ("pytest-sentry.rerun" , is_rerun )
9583            if  is_rerun :
@@ -107,7 +95,7 @@ def pytest_fixture_setup(fixturedef, request):
10795    op  =  "pytest.fixture.setup" 
10896    name  =  "{} {}" .format (op , fixturedef .argname )
10997
110-     with  sentry_sdk .continue_trace (dict (sentry_sdk .get_current_scope ().iter_trace_propagation_headers ())):
98+     with  sentry_sdk .continue_trace (dict (sentry_sdk .get_isolation_scope ().iter_trace_propagation_headers ())):
11199        with  sentry_sdk .start_span (op = op , name = name ) as  root_span :
112100            root_span .set_tag ("pytest.fixture.scope" , fixturedef .scope )
113101            yield 
@@ -135,8 +123,8 @@ def pytest_runtest_makereport(item, call):
135123                call .excinfo 
136124            ]
137125
138-         scope  =  _resolve_scope_marker_value (item .get_closest_marker ("sentry_client" ))
139-         integration  =  scope .client .get_integration (PytestIntegration )
126+         isolation_scope  =  _resolve_scope_marker_value (item .get_closest_marker ("sentry_client" ))
127+         integration  =  isolation_scope .client .get_integration (PytestIntegration )
140128
141129        if  (cur_exc_chain  and  call .excinfo  is  None ) or  (integration  is  not   None  and  integration .always_report ):
142130            for  exc_info  in  cur_exc_chain :
0 commit comments