diff --git a/sentry_sdk/_init_implementation.py b/sentry_sdk/_init_implementation.py index 74bbd9a20f..4ad110ab56 100644 --- a/sentry_sdk/_init_implementation.py +++ b/sentry_sdk/_init_implementation.py @@ -23,9 +23,9 @@ def _init(*args, **kwargs): This takes the same arguments as the client constructor. """ + setup_scope_context_management() client = sentry_sdk.Client(*args, **kwargs) sentry_sdk.get_global_scope().set_client(client) - setup_scope_context_management() _check_python_deprecations() diff --git a/tests/conftest.py b/tests/conftest.py index 70f86b6905..d067e04eb5 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -199,10 +199,10 @@ def inner(identifier): @pytest.fixture def sentry_init(request): def inner(*a, **kw): + setup_scope_context_management() kw.setdefault("transport", TestTransport()) client = sentry_sdk.Client(*a, **kw) sentry_sdk.get_global_scope().set_client(client) - setup_scope_context_management() if request.node.get_closest_marker("forked"): # Do not run isolation if the test is already running in