Skip to content

Commit

Permalink
Code review
Browse files Browse the repository at this point in the history
  • Loading branch information
szokeasaurusrex committed Mar 12, 2024
1 parent 448db6d commit fad8ced
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pytest_sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from sentry_sdk import Scope, capture_exception
from sentry_sdk.tracing import Transaction
from sentry_sdk.scope import add_global_event_processor, use_isolation_scope
from sentry_sdk.scope import add_global_event_processor, use_scope

_ENVVARS_AS_TAGS = frozenset(
[
Expand Down Expand Up @@ -111,17 +111,17 @@ def _with_scope(wrapped, instance, args, kwargs):
if scope.client.get_integration(PytestIntegration) is None:
yield
else:
with use_isolation_scope(scope): # TODO: What do we do with scope here?
with use_scope(scope):
gen = wrapped(*args, **kwargs)

while True:
try:
with use_isolation_scope(scope):
with use_scope(scope):
chunk = next(gen)

y = yield chunk

with use_isolation_scope(scope):
with use_scope(scope):
gen.send(y)

except StopIteration:
Expand Down
5 changes: 5 additions & 0 deletions tests/test_scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ def test_basic():
_assert_right_scopes()


def test_sentry_test_scope(sentry_test_scope):
# Ensure that we are within a transaction (started by the fixture)
assert sentry_test_scope.span is not None


class TestSimpleClass(object):
def setup_method(self):
_assert_right_scopes()
Expand Down

0 comments on commit fad8ced

Please sign in to comment.