Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 0 additions & 71 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import os
import socket
import threading
import warnings
from collections import namedtuple
from dataclasses import dataclass
from http.server import BaseHTTPRequestHandler, HTTPServer
Expand Down Expand Up @@ -42,11 +41,6 @@
except (ImportError, RuntimeError):
TestClient = None

try:
import gevent
except ImportError:
gevent = None

import sentry_sdk
import sentry_sdk.utils
from sentry_sdk.envelope import Envelope, parse_json
Expand Down Expand Up @@ -489,37 +483,6 @@ def record_lost_event(reason, data_category=None, item=None, *, quantity=1):
return inner


@pytest.fixture
def capture_events_forksafe(monkeypatch, capture_events, request):
def inner():
capture_events()

events_r, events_w = os.pipe()
events_r = os.fdopen(events_r, "rb", 0)
events_w = os.fdopen(events_w, "wb", 0)

test_client = sentry_sdk.get_client()

old_capture_envelope = test_client.transport.capture_envelope

def append(envelope):
event = envelope.get_event()
if event is not None:
events_w.write(json.dumps(event).encode("utf-8"))
events_w.write(b"\n")
return old_capture_envelope(envelope)

def flush(timeout=None, callback=None):
events_w.write(b"flush\n")

monkeypatch.setattr(test_client.transport, "capture_envelope", append)
monkeypatch.setattr(test_client, "flush", flush)

return EventStreamReader(events_r, events_w)

return inner


@pytest.fixture
def capture_items_forksafe(monkeypatch, capture_items, request):
def inner(*types):
Expand Down Expand Up @@ -578,29 +541,6 @@ def read_flush(self):
assert self.read_file.readline() == b"flush\n"


# scope=session ensures that fixture is run earlier
@pytest.fixture(
scope="session",
params=[None, "gevent"],
ids=("threads", "greenlet"),
)
def maybe_monkeypatched_threading(request):
if request.param == "gevent":
if gevent is None:
pytest.skip("no gevent installed")
try:
gevent.monkey.patch_all()
except Exception as e:
if "_RLock__owner" in str(e):
pytest.skip("https://github.com/gevent/gevent/issues/1380")
else:
raise
else:
assert request.param is None

return request.param


@pytest.fixture
def render_span_tree():
def inner(spans):
Expand Down Expand Up @@ -815,17 +755,6 @@ def teardown_profiling():
teardown_continuous_profiler()


@pytest.fixture()
def suppress_deprecation_warnings():
"""
Use this fixture to suppress deprecation warnings in a test.
Useful for testing deprecated SDK features.
"""
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
yield


def _make_session_message(jsonrpc_msg):
"""Construct a SessionMessage compatible with both MCP v1 and v2."""
if _IS_MCP_V2:
Expand Down
1 change: 0 additions & 1 deletion tests/integrations/asgi/test_asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,6 @@ async def test_websocket(
sentry_init,
asgi3_ws_app,
capture_items,
request,
):
sentry_init(
data_collection={},
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/asyncio/test_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ async def test_delayed_enable_integration(

@minimum_python_38
@pytest.mark.asyncio
async def test_delayed_enable_integration_with_options(sentry_init, capture_events):
async def test_delayed_enable_integration_with_options(sentry_init):
sentry_init(
traces_sample_rate=1.0,
data_collection={},
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/beam/test_beam.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def test_invoker_normal(init_beam, fn):


@pytest.mark.parametrize("fn", [test_simple, test_callable, test_place_holder])
def test_invoker_exception(init_beam, capture_events, capture_exceptions, fn):
def test_invoker_exception(init_beam, capture_events, fn):
invoker = init_beam(fn)
events = capture_events()

Expand Down
3 changes: 1 addition & 2 deletions tests/integrations/bottle/test_bottle.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def index():
assert len(events) == 1


def test_mount(app, capture_exceptions, capture_events, sentry_init, get_client):
def test_mount(app, capture_exceptions, capture_events, sentry_init):
sentry_init(integrations=[BottleIntegration()])

app.catchall = False
Expand Down Expand Up @@ -437,7 +437,6 @@ def here():
def test_span_origin(
sentry_init,
get_client,
capture_events,
capture_items,
):
sentry_init(
Expand Down
10 changes: 0 additions & 10 deletions tests/integrations/celery/test_celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,6 @@
from sentry_sdk.integrations.celery.beat import _get_headers


@pytest.fixture
def connect_signal(request):
def inner(signal, f):
signal.connect(f)
request.addfinalizer(lambda: signal.disconnect(f))

return inner


@pytest.fixture
def init_celery(sentry_init, request):
def inner(
Expand Down Expand Up @@ -53,7 +44,6 @@ def inner(
if VERSION < (4,):
pytest.skip("Redis backend broken for some reason")

# this backend requires capture_events_forksafe
celery.conf.worker_max_tasks_per_child = 1
celery.conf.worker_concurrency = 1
redis_url = f"redis://{os.environ.get('SENTRY_PYTHON_TEST_REDIS_HOST', '127.0.0.1')}:6379"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,6 @@ def test_clickhouse_dbapi_breadcrumbs(sentry_init, capture_events) -> None:
def test_clickhouse_dbapi_spans(
sentry_init,
capture_items,
capture_envelopes,
):
sentry_init(
integrations=[ClickhouseDriverIntegration()],
Expand Down Expand Up @@ -878,7 +877,7 @@ def test_clickhouse_dbapi_spans(
assert spans == expected_spans


def test_span_origin(sentry_init, capture_items, capture_envelopes):
def test_span_origin(sentry_init, capture_items):
sentry_init(
integrations=[ClickhouseDriverIntegration()],
traces_sample_rate=1.0,
Expand Down
1 change: 0 additions & 1 deletion tests/integrations/dramatiq/test_dramatiq.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ def dummy_actor(x, y):
def test_task_transaction(
broker,
worker,
capture_events,
capture_items,
expected_span_status,
fail_fast,
Expand Down
14 changes: 4 additions & 10 deletions tests/integrations/flask/test_flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ def test_has_context(sentry_init, app, capture_events):
def test_segment_name_and_source(
sentry_init,
app,
capture_events,
capture_items,
url,
expected_transaction,
Expand Down Expand Up @@ -209,7 +208,7 @@ def test_flask_login_not_installed(


def test_flask_login_not_configured(
sentry_init, app, capture_events, monkeypatch, integration_enabled_params
sentry_init, app, capture_events, integration_enabled_params
):
sentry_init(data_collection={"user_info": False}, **integration_enabled_params)

Expand All @@ -227,7 +226,7 @@ def test_flask_login_not_configured(


def test_flask_login_partially_configured(
sentry_init, app, capture_events, monkeypatch, integration_enabled_params
sentry_init, app, capture_events, integration_enabled_params
):
sentry_init(data_collection={"user_info": False}, **integration_enabled_params)

Expand Down Expand Up @@ -257,9 +256,7 @@ def test_flask_login_configured(
sentry_init,
app,
user_id,
capture_events,
capture_items,
monkeypatch,
integration_enabled_params,
):
sentry_init(
Expand Down Expand Up @@ -801,7 +798,6 @@ def zerodivision(e):

def test_tracing_success(
sentry_init,
capture_events,
capture_items,
app,
):
Expand Down Expand Up @@ -847,7 +843,7 @@ def hi_tx():
assert message_event["tags"]["before_request"] == "yes"


def test_tracing_error(sentry_init, capture_events, capture_items, app):
def test_tracing_error(sentry_init, capture_items, app):
sentry_init(
data_collection={},
traces_sample_rate=1.0,
Expand Down Expand Up @@ -1011,7 +1007,7 @@ def index():
assert event["request"]["headers"]["Proxy-Authorization"] == "[Filtered]"


def test_span_origin(sentry_init, app, capture_events, capture_items):
def test_span_origin(sentry_init, app, capture_items):
sentry_init(
data_collection={},
integrations=[flask_sentry.FlaskIntegration()],
Expand All @@ -1034,7 +1030,6 @@ def test_span_origin(sentry_init, app, capture_events, capture_items):
def test_segment_http_method_default(
sentry_init,
app,
capture_events,
capture_items,
):
"""
Expand Down Expand Up @@ -1069,7 +1064,6 @@ def test_segment_http_method_default(
def test_segment_http_method_custom(
sentry_init,
app,
capture_events,
capture_items,
):
"""
Expand Down
6 changes: 0 additions & 6 deletions tests/integrations/langchain/test_langchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -2998,7 +2998,6 @@ def test_transform_list_with_legacy_image_url(self):
)
def test_langchain_chat_data_collection(
sentry_init,
capture_events,
capture_items,
get_model_response,
nonstreaming_chat_completions_model_response,
Expand Down Expand Up @@ -3106,7 +3105,6 @@ def test_langchain_chat_data_collection(
)
def test_langchain_text_completion_data_collection(
sentry_init,
capture_events,
capture_items,
get_model_response,
data_collection,
Expand Down Expand Up @@ -3210,7 +3208,6 @@ def test_langchain_text_completion_data_collection(
)
def test_langchain_data_collection_tools(
sentry_init,
capture_events,
capture_items,
get_model_response,
server_side_event_chunks,
Expand Down Expand Up @@ -3310,7 +3307,6 @@ def test_langchain_data_collection_tools(
)
def test_langchain_data_collection_request_tool_call_params(
sentry_init,
capture_events,
capture_items,
data_collection,
tool_calls_collected,
Expand Down Expand Up @@ -3378,7 +3374,6 @@ def test_langchain_data_collection_request_tool_call_params(
)
def test_langchain_tool_execution_data_collection(
sentry_init,
capture_events,
capture_items,
get_model_response,
server_side_event_chunks,
Expand Down Expand Up @@ -3476,7 +3471,6 @@ def test_langchain_tool_execution_data_collection(
)
def test_langchain_agent_executor_data_collection(
sentry_init,
capture_events,
capture_items,
get_model_response,
server_side_event_chunks,
Expand Down
1 change: 0 additions & 1 deletion tests/integrations/launchdarkly/test_launchdarkly.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ def test_launchdarkly_integration_did_not_enable(uninstall_integration):

def test_launchdarkly_span_integration(
sentry_init,
capture_events,
capture_items,
uninstall_integration,
):
Expand Down
4 changes: 2 additions & 2 deletions tests/integrations/logging/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def test_event_logging_captured_warnings(sentry_init, capture_events, recwarn):
assert len(third_warnings) == 1


def test_sentry_logs_collection_off_by_default(sentry_init, capture_items, request):
def test_sentry_logs_collection_off_by_default(sentry_init, capture_items):
"""Automatic logs capture by Sentry logs needs explicit opt-in to the integration."""
sentry_init()
items = capture_items("log")
Expand All @@ -312,7 +312,7 @@ def test_sentry_logs_collection_off_by_default(sentry_init, capture_items, reque
assert not items


def test_sentry_logs_collection_opt_in(sentry_init, capture_items, request):
def test_sentry_logs_collection_opt_in(sentry_init, capture_items):
"""Automatic logs capture by Sentry logs needs explicit opt-in to the integration."""
sentry_init(integrations=[LoggingIntegration()])
items = capture_items("log")
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/loguru/test_loguru.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def test_levels(
assert log.payload["attributes"]["sentry.origin"] == "auto.log.loguru"


def test_breadcrumb_format(sentry_init, capture_events, uninstall_integration, request):
def test_breadcrumb_format(sentry_init, uninstall_integration, request):
uninstall_integration("loguru")
request.addfinalizer(logger.remove)

Expand Down
1 change: 0 additions & 1 deletion tests/integrations/openfeature/test_openfeature.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ async def runner():

def test_openfeature_span_integration(
sentry_init,
capture_events,
capture_items,
uninstall_integration,
):
Expand Down
2 changes: 1 addition & 1 deletion tests/integrations/pyramid/test_pyramid.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ def error_handler(err, request):


def test_error_in_authenticated_userid(
sentry_init, pyramid_config, capture_events, route, get_client
sentry_init, pyramid_config, capture_events, get_client
):
from sentry_sdk.integrations.logging import LoggingIntegration

Expand Down
1 change: 0 additions & 1 deletion tests/integrations/quart/test_quart.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ async def test_quart_auth_configured(
sentry_init,
user_id,
capture_events,
monkeypatch,
integration_enabled_params,
):
from quart_auth import AuthUser, login_user
Expand Down
Loading
Loading