@@ -27,31 +27,26 @@ 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 )
3939
40- while True :
41- try :
42- with sentry_sdk .use_scope (scope ):
40+ while True :
41+ try :
4342 chunk = next (gen )
44-
45- y = yield chunk
46-
47- with sentry_sdk .use_scope (scope ):
43+ y = yield chunk
4844 gen .send (y )
49-
50- except StopIteration :
51- break
45+ except StopIteration :
46+ break
5247
5348 def inner (f ):
54- return pytest .hookimpl (hookwrapper = True , ** kwargs )(_with_scope (f ))
49+ return pytest .hookimpl (hookwrapper = True , ** kwargs )(_with_isolation_scope (f ))
5550
5651 return inner
5752
@@ -89,7 +84,7 @@ def pytest_runtest_call(item):
8984
9085 # We use the full name including parameters because then we can identify
9186 # 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 ())):
87+ with sentry_sdk .continue_trace (dict (sentry_sdk .get_isolation_scope ().iter_trace_propagation_headers ())):
9388 with sentry_sdk .start_span (op = op , name = name ) as span :
9489 span .set_attribute ("pytest-sentry.rerun" , is_rerun )
9590 if is_rerun :
@@ -107,7 +102,7 @@ def pytest_fixture_setup(fixturedef, request):
107102 op = "pytest.fixture.setup"
108103 name = "{} {}" .format (op , fixturedef .argname )
109104
110- with sentry_sdk .continue_trace (dict (sentry_sdk .get_current_scope ().iter_trace_propagation_headers ())):
105+ with sentry_sdk .continue_trace (dict (sentry_sdk .get_isolation_scope ().iter_trace_propagation_headers ())):
111106 with sentry_sdk .start_span (op = op , name = name ) as root_span :
112107 root_span .set_tag ("pytest.fixture.scope" , fixturedef .scope )
113108 yield
@@ -135,8 +130,8 @@ def pytest_runtest_makereport(item, call):
135130 call .excinfo
136131 ]
137132
138- scope = _resolve_scope_marker_value (item .get_closest_marker ("sentry_client" ))
139- integration = scope .client .get_integration (PytestIntegration )
133+ isolation_scope = _resolve_scope_marker_value (item .get_closest_marker ("sentry_client" ))
134+ integration = isolation_scope .client .get_integration (PytestIntegration )
140135
141136 if (cur_exc_chain and call .excinfo is None ) or (integration is not None and integration .always_report ):
142137 for exc_info in cur_exc_chain :
0 commit comments