From 8d4df26ae5ee521b38237bd3a62e6ea1af735bbc Mon Sep 17 00:00:00 2001 From: Daniel Szoke Date: Wed, 10 Jul 2024 19:06:00 +0200 Subject: [PATCH] fix tests hopefully --- tests/new_scopes_compat/__init__.py | 7 +++++++ tests/new_scopes_compat/conftest.py | 8 ++++++++ tests/{ => new_scopes_compat}/test_new_scopes_compat.py | 8 -------- .../test_new_scopes_compat_event.py | 4 ++-- 4 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 tests/new_scopes_compat/__init__.py create mode 100644 tests/new_scopes_compat/conftest.py rename tests/{ => new_scopes_compat}/test_new_scopes_compat.py (98%) rename tests/{ => new_scopes_compat}/test_new_scopes_compat_event.py (98%) diff --git a/tests/new_scopes_compat/__init__.py b/tests/new_scopes_compat/__init__.py new file mode 100644 index 0000000000..45391bd9ad --- /dev/null +++ b/tests/new_scopes_compat/__init__.py @@ -0,0 +1,7 @@ +""" +Separate module for tests that check backwards compatibility of the Hub API with 1.x. +These tests should be removed once we remove the Hub API, likely in the next major. + +All tests in this module are run with hub isolation, provided by `isolate_hub` autouse +fixture, defined in `conftest.py`. +""" diff --git a/tests/new_scopes_compat/conftest.py b/tests/new_scopes_compat/conftest.py new file mode 100644 index 0000000000..3afcf91704 --- /dev/null +++ b/tests/new_scopes_compat/conftest.py @@ -0,0 +1,8 @@ +import pytest +import sentry_sdk + + +@pytest.fixture(autouse=True) +def isolate_hub(): + with sentry_sdk.Hub(None): + yield diff --git a/tests/test_new_scopes_compat.py b/tests/new_scopes_compat/test_new_scopes_compat.py similarity index 98% rename from tests/test_new_scopes_compat.py rename to tests/new_scopes_compat/test_new_scopes_compat.py index 77f5401b2d..21e2ac27d3 100644 --- a/tests/test_new_scopes_compat.py +++ b/tests/new_scopes_compat/test_new_scopes_compat.py @@ -1,5 +1,3 @@ -import pytest - import sentry_sdk from sentry_sdk.hub import Hub @@ -13,12 +11,6 @@ """ -@pytest.fixture(autouse=True) -def isolate_hub(): - with sentry_sdk.Hub(None): - yield - - def test_configure_scope_sdk1(sentry_init, capture_events): """ Mutate data in a `with configure_scope` block. diff --git a/tests/test_new_scopes_compat_event.py b/tests/new_scopes_compat/test_new_scopes_compat_event.py similarity index 98% rename from tests/test_new_scopes_compat_event.py rename to tests/new_scopes_compat/test_new_scopes_compat_event.py index 53eb095b5e..fd43a25c69 100644 --- a/tests/test_new_scopes_compat_event.py +++ b/tests/new_scopes_compat/test_new_scopes_compat_event.py @@ -32,10 +32,10 @@ def create_expected_error_event(trx, span): "stacktrace": { "frames": [ { - "filename": "tests/test_new_scopes_compat_event.py", + "filename": "tests/new_scopes_compat/test_new_scopes_compat_event.py", "abs_path": mock.ANY, "function": "_faulty_function", - "module": "tests.test_new_scopes_compat_event", + "module": "tests.new_scopes_compat.test_new_scopes_compat_event", "lineno": mock.ANY, "pre_context": [ " return create_expected_transaction_event",