From fad8cedcbdc2aa8fe5c5b2450d1e11830ec7af8b Mon Sep 17 00:00:00 2001 From: Daniel Szoke Date: Tue, 12 Mar 2024 15:21:01 +0100 Subject: [PATCH] Code review --- pytest_sentry.py | 8 ++++---- tests/test_scope.py | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pytest_sentry.py b/pytest_sentry.py index 9fa3d40..57db670 100644 --- a/pytest_sentry.py +++ b/pytest_sentry.py @@ -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( [ @@ -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: diff --git a/tests/test_scope.py b/tests/test_scope.py index c212623..065c507 100644 --- a/tests/test_scope.py +++ b/tests/test_scope.py @@ -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()