Skip to content

Commit 83992b3

Browse files
committed
Removed Hub from basic tests
1 parent 6e876e5 commit 83992b3

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

tests/integrations/conftest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ def inner():
1010
old_capture_event_scope = sentry_sdk.Scope.capture_event
1111

1212
def capture_event_hub(self, event, hint=None, scope=None):
13+
"""
14+
Can be removed when we remove push_scope and the Hub from the SDK.
15+
"""
1316
if hint:
1417
if "exc_info" in hint:
1518
error = hint["exc_info"][1]

tests/test_basics.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from tests.conftest import patch_start_tracing_child
1010

11+
import sentry_sdk
1112
from sentry_sdk import (
1213
push_scope,
1314
configure_scope,
@@ -220,7 +221,7 @@ def before_breadcrumb(crumb, hint):
220221
events = capture_events()
221222

222223
monkeypatch.setattr(
223-
Hub.current.client.transport, "record_lost_event", record_lost_event
224+
sentry_sdk.get_client().transport, "record_lost_event", record_lost_event
224225
)
225226

226227
def do_this():
@@ -269,7 +270,7 @@ def test_option_enable_tracing(
269270
updated_traces_sample_rate,
270271
):
271272
sentry_init(enable_tracing=enable_tracing, traces_sample_rate=traces_sample_rate)
272-
options = Hub.current.client.options
273+
options = sentry_sdk.get_client().options
273274
assert has_tracing_enabled(options) is tracing_enabled
274275
assert options["traces_sample_rate"] == updated_traces_sample_rate
275276

@@ -311,6 +312,9 @@ def test_push_scope(sentry_init, capture_events):
311312

312313

313314
def test_push_scope_null_client(sentry_init, capture_events):
315+
"""
316+
This test can be removed when we remove push_scope and the Hub from the SDK.
317+
"""
314318
sentry_init()
315319
events = capture_events()
316320

@@ -331,6 +335,9 @@ def test_push_scope_null_client(sentry_init, capture_events):
331335
)
332336
@pytest.mark.parametrize("null_client", (True, False))
333337
def test_push_scope_callback(sentry_init, null_client, capture_events):
338+
"""
339+
This test can be removed when we remove push_scope and the Hub from the SDK.
340+
"""
334341
sentry_init()
335342

336343
if null_client:
@@ -439,6 +446,9 @@ def test_integration_scoping(sentry_init, capture_events):
439446
reason="This test is not valid anymore, because with the new Scopes calling bind_client on the Hub sets the client on the global scope. This test should be removed once the Hub is removed"
440447
)
441448
def test_client_initialized_within_scope(sentry_init, caplog):
449+
"""
450+
This test can be removed when we remove push_scope and the Hub from the SDK.
451+
"""
442452
caplog.set_level(logging.WARNING)
443453

444454
sentry_init()
@@ -455,6 +465,9 @@ def test_client_initialized_within_scope(sentry_init, caplog):
455465
reason="This test is not valid anymore, because with the new Scopes the push_scope just returns the isolation scope. This test should be removed once the Hub is removed"
456466
)
457467
def test_scope_leaks_cleaned_up(sentry_init, caplog):
468+
"""
469+
This test can be removed when we remove push_scope and the Hub from the SDK.
470+
"""
458471
caplog.set_level(logging.WARNING)
459472

460473
sentry_init()
@@ -475,6 +488,9 @@ def test_scope_leaks_cleaned_up(sentry_init, caplog):
475488
reason="This test is not valid anymore, because with the new Scopes there is not pushing and popping of scopes. This test should be removed once the Hub is removed"
476489
)
477490
def test_scope_popped_too_soon(sentry_init, caplog):
491+
"""
492+
This test can be removed when we remove push_scope and the Hub from the SDK.
493+
"""
478494
caplog.set_level(logging.ERROR)
479495

480496
sentry_init()
@@ -719,7 +735,7 @@ def test_functions_to_trace_with_class(sentry_init, capture_events):
719735
def test_redis_disabled_when_not_installed(sentry_init):
720736
sentry_init()
721737

722-
assert Hub.current.get_integration(RedisIntegration) is None
738+
assert sentry_sdk.get_client().get_integration(RedisIntegration) is None
723739

724740

725741
def test_multiple_setup_integrations_calls():

0 commit comments

Comments
 (0)