Skip to content

Fix starlette tests #3749

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 11, 2024
Merged
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
36 changes: 17 additions & 19 deletions tests/integrations/starlette/test_starlette.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,9 +659,9 @@ def test_middleware_spans(sentry_init, capture_events):
"AuthenticationMiddleware",
"ExceptionMiddleware",
"AuthenticationMiddleware", # 'op': 'middleware.starlette.send'
"ServerErrorMiddleware", # 'op': 'middleware.starlette.send'
"AuthenticationMiddleware", # 'op': 'middleware.starlette.send'
"ServerErrorMiddleware", # 'op': 'middleware.starlette.send'
"ServerErrorMiddleware", # 'op': 'middleware.starlette.send'
]

assert len(transaction_event["spans"]) == len(expected_middleware_spans)
Expand Down Expand Up @@ -736,23 +736,23 @@ def test_middleware_callback_spans(sentry_init, capture_events):
},
{
"op": "middleware.starlette.send",
"description": "ServerErrorMiddleware.__call__.<locals>._send",
"tags": {"starlette.middleware_name": "SampleMiddleware"},
"description": "SampleMiddleware.__call__.<locals>.do_stuff",
"tags": {"starlette.middleware_name": "ExceptionMiddleware"},
},
{
"op": "middleware.starlette.send",
"description": "SentryAsgiMiddleware._run_app.<locals>._sentry_wrapped_send",
"tags": {"starlette.middleware_name": "ServerErrorMiddleware"},
"description": "ServerErrorMiddleware.__call__.<locals>._send",
"tags": {"starlette.middleware_name": "SampleMiddleware"},
},
{
"op": "middleware.starlette.send",
"description": "SampleMiddleware.__call__.<locals>.do_stuff",
"tags": {"starlette.middleware_name": "ExceptionMiddleware"},
"description": "ServerErrorMiddleware.__call__.<locals>._send",
"tags": {"starlette.middleware_name": "SampleMiddleware"},
},
{
"op": "middleware.starlette.send",
"description": "ServerErrorMiddleware.__call__.<locals>._send",
"tags": {"starlette.middleware_name": "SampleMiddleware"},
"description": "SentryAsgiMiddleware._run_app.<locals>._sentry_wrapped_send",
"tags": {"starlette.middleware_name": "ServerErrorMiddleware"},
},
{
"op": "middleware.starlette.send",
Expand Down Expand Up @@ -830,16 +830,16 @@ def test_middleware_partial_receive_send(sentry_init, capture_events):
"description": "ServerErrorMiddleware.__call__.<locals>._send",
"tags": {"starlette.middleware_name": "SamplePartialReceiveSendMiddleware"},
},
{
"op": "middleware.starlette.send",
"description": "SentryAsgiMiddleware._run_app.<locals>._sentry_wrapped_send",
"tags": {"starlette.middleware_name": "ServerErrorMiddleware"},
},
{
"op": "middleware.starlette",
"description": "ExceptionMiddleware",
"tags": {"starlette.middleware_name": "ExceptionMiddleware"},
},
{
"op": "middleware.starlette.send",
"description": "SentryAsgiMiddleware._run_app.<locals>._sentry_wrapped_send",
"tags": {"starlette.middleware_name": "ServerErrorMiddleware"},
},
{
"op": "middleware.starlette.send",
"description": "functools.partial(<function SamplePartialReceiveSendMiddleware.__call__.<locals>.my_send at ",
Expand Down Expand Up @@ -886,13 +886,13 @@ def test_active_thread_id(sentry_init, capture_envelopes, teardown_profiling, en
sentry_init(
traces_sample_rate=1.0,
profiles_sample_rate=1.0,
integrations=[StarletteIntegration()],
)
app = starlette_app_factory()
asgi_app = SentryAsgiMiddleware(app)

envelopes = capture_envelopes()

client = TestClient(asgi_app)
client = TestClient(app)
response = client.get(endpoint)
assert response.status_code == 200

Expand Down Expand Up @@ -1244,9 +1244,7 @@ def test_transaction_http_method_default(sentry_init, capture_events):
"""
sentry_init(
traces_sample_rate=1.0,
integrations=[
StarletteIntegration(),
],
integrations=[StarletteIntegration()],
)
events = capture_events()

Expand Down
Loading