Skip to content

Commit

Permalink
Removed Hub from basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
antonpirker committed Jun 25, 2024
1 parent 6e876e5 commit 83992b3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
3 changes: 3 additions & 0 deletions tests/integrations/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ def inner():
old_capture_event_scope = sentry_sdk.Scope.capture_event

def capture_event_hub(self, event, hint=None, scope=None):
"""
Can be removed when we remove push_scope and the Hub from the SDK.
"""
if hint:
if "exc_info" in hint:
error = hint["exc_info"][1]
Expand Down
22 changes: 19 additions & 3 deletions tests/test_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from tests.conftest import patch_start_tracing_child

import sentry_sdk
from sentry_sdk import (
push_scope,
configure_scope,
Expand Down Expand Up @@ -220,7 +221,7 @@ def before_breadcrumb(crumb, hint):
events = capture_events()

monkeypatch.setattr(
Hub.current.client.transport, "record_lost_event", record_lost_event
sentry_sdk.get_client().transport, "record_lost_event", record_lost_event
)

def do_this():
Expand Down Expand Up @@ -269,7 +270,7 @@ def test_option_enable_tracing(
updated_traces_sample_rate,
):
sentry_init(enable_tracing=enable_tracing, traces_sample_rate=traces_sample_rate)
options = Hub.current.client.options
options = sentry_sdk.get_client().options
assert has_tracing_enabled(options) is tracing_enabled
assert options["traces_sample_rate"] == updated_traces_sample_rate

Expand Down Expand Up @@ -311,6 +312,9 @@ def test_push_scope(sentry_init, capture_events):


def test_push_scope_null_client(sentry_init, capture_events):
"""
This test can be removed when we remove push_scope and the Hub from the SDK.
"""
sentry_init()
events = capture_events()

Expand All @@ -331,6 +335,9 @@ def test_push_scope_null_client(sentry_init, capture_events):
)
@pytest.mark.parametrize("null_client", (True, False))
def test_push_scope_callback(sentry_init, null_client, capture_events):
"""
This test can be removed when we remove push_scope and the Hub from the SDK.
"""
sentry_init()

if null_client:
Expand Down Expand Up @@ -439,6 +446,9 @@ def test_integration_scoping(sentry_init, capture_events):
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"
)
def test_client_initialized_within_scope(sentry_init, caplog):
"""
This test can be removed when we remove push_scope and the Hub from the SDK.
"""
caplog.set_level(logging.WARNING)

sentry_init()
Expand All @@ -455,6 +465,9 @@ def test_client_initialized_within_scope(sentry_init, caplog):
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"
)
def test_scope_leaks_cleaned_up(sentry_init, caplog):
"""
This test can be removed when we remove push_scope and the Hub from the SDK.
"""
caplog.set_level(logging.WARNING)

sentry_init()
Expand All @@ -475,6 +488,9 @@ def test_scope_leaks_cleaned_up(sentry_init, caplog):
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"
)
def test_scope_popped_too_soon(sentry_init, caplog):
"""
This test can be removed when we remove push_scope and the Hub from the SDK.
"""
caplog.set_level(logging.ERROR)

sentry_init()
Expand Down Expand Up @@ -719,7 +735,7 @@ def test_functions_to_trace_with_class(sentry_init, capture_events):
def test_redis_disabled_when_not_installed(sentry_init):
sentry_init()

assert Hub.current.get_integration(RedisIntegration) is None
assert sentry_sdk.get_client().get_integration(RedisIntegration) is None


def test_multiple_setup_integrations_calls():
Expand Down

0 comments on commit 83992b3

Please sign in to comment.