From 91094202efee158dea2f8e60ba54d936a953cd32 Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Tue, 26 May 2026 11:47:36 +0200 Subject: [PATCH 1/3] test(django): Remove pytest.mark.forked from ASGI Django tests --- tests/integrations/django/asgi/test_asgi.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/tests/integrations/django/asgi/test_asgi.py b/tests/integrations/django/asgi/test_asgi.py index d1b2374305..1f5a590170 100644 --- a/tests/integrations/django/asgi/test_asgi.py +++ b/tests/integrations/django/asgi/test_asgi.py @@ -32,7 +32,6 @@ @pytest.mark.parametrize("application", APPS) @pytest.mark.asyncio -@pytest.mark.forked @pytest.mark.skipif( django.VERSION < (3, 0), reason="Django ASGI support shipped in 3.0" ) @@ -140,7 +139,6 @@ async def test_basic( @pytest.mark.parametrize("application", APPS) @pytest.mark.asyncio -@pytest.mark.forked @pytest.mark.skipif( django.VERSION < (3, 1), reason="async views have been introduced in Django 3.1" ) @@ -192,7 +190,6 @@ async def test_async_views( @pytest.mark.parametrize("endpoint", ["/sync/thread_ids", "/async/thread_ids"]) @pytest.mark.parametrize("middleware_spans", [False, True]) @pytest.mark.asyncio -@pytest.mark.forked @pytest.mark.skipif( django.VERSION < (3, 1), reason="async views have been introduced in Django 3.1" ) @@ -269,7 +266,6 @@ async def test_active_thread_id( @pytest.mark.asyncio -@pytest.mark.forked @pytest.mark.skipif( django.VERSION < (3, 1), reason="async views have been introduced in Django 3.1" ) @@ -312,7 +308,6 @@ async def test_async_views_concurrent_execution(sentry_init, settings): @pytest.mark.asyncio -@pytest.mark.forked @pytest.mark.skipif( django.VERSION < (3, 1), reason="async views have been introduced in Django 3.1" ) @@ -359,7 +354,6 @@ async def test_async_middleware_that_is_function_concurrent_execution( @pytest.mark.asyncio -@pytest.mark.forked @pytest.mark.skipif( django.VERSION < (3, 1), reason="async views have been introduced in Django 3.1" ) @@ -447,7 +441,6 @@ async def test_async_middleware_spans( @pytest.mark.asyncio -@pytest.mark.forked @pytest.mark.skipif( django.VERSION < (3, 1), reason="async views have been introduced in Django 3.1" ) @@ -505,7 +498,6 @@ async def test_has_trace_if_performance_enabled( @pytest.mark.asyncio -@pytest.mark.forked @pytest.mark.skipif( django.VERSION < (3, 1), reason="async views have been introduced in Django 3.1" ) @@ -556,7 +548,6 @@ async def test_has_trace_if_performance_disabled( @pytest.mark.asyncio -@pytest.mark.forked @pytest.mark.skipif( django.VERSION < (3, 1), reason="async views have been introduced in Django 3.1" ) @@ -619,7 +610,6 @@ async def test_trace_from_headers_if_performance_enabled( @pytest.mark.asyncio -@pytest.mark.forked @pytest.mark.skipif( django.VERSION < (3, 1), reason="async views have been introduced in Django 3.1" ) From f0ac0de0fc79064f1104d812328fb343ac154b01 Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Tue, 26 May 2026 13:32:25 +0200 Subject: [PATCH 2/3] comment out one test --- tests/integrations/django/asgi/test_asgi.py | 211 ++++++++++---------- 1 file changed, 105 insertions(+), 106 deletions(-) diff --git a/tests/integrations/django/asgi/test_asgi.py b/tests/integrations/django/asgi/test_asgi.py index 1f5a590170..050dd0dd3b 100644 --- a/tests/integrations/django/asgi/test_asgi.py +++ b/tests/integrations/django/asgi/test_asgi.py @@ -11,7 +11,6 @@ from channels.testing import HttpCommunicator import sentry_sdk -from sentry_sdk import capture_message from sentry_sdk.consts import SPANDATA from sentry_sdk.integrations.django import DjangoIntegration from sentry_sdk.integrations.django.asgi import _asgi_middleware_mixin_factory @@ -30,111 +29,111 @@ APPS += [asgi_application] -@pytest.mark.parametrize("application", APPS) -@pytest.mark.asyncio -@pytest.mark.skipif( - django.VERSION < (3, 0), reason="Django ASGI support shipped in 3.0" -) -@pytest.mark.parametrize("span_streaming", [True, False]) -async def test_basic( - sentry_init, - capture_events, - capture_items, - application, - span_streaming, -): - sentry_init( - integrations=[DjangoIntegration()], - send_default_pii=True, - _experiments={"trace_lifecycle": "stream" if span_streaming else "static"}, - ) - - import channels # type: ignore[import-not-found] - - if span_streaming: - items = capture_items("event") - - if ( - sys.version_info < (3, 9) - and channels.__version__ < "4.0.0" - and django.VERSION >= (3, 0) - and django.VERSION < (4, 0) - ): - # We emit a UserWarning for channels 2.x and 3.x on Python 3.8 and older - # because the async support was not really good back then and there is a known issue. - # See the TreadingIntegration for details. - with pytest.warns(UserWarning): - comm = HttpCommunicator(application, "GET", "/view-exc?test=query") - response = await comm.get_response() - await comm.wait() - else: - comm = HttpCommunicator(application, "GET", "/view-exc?test=query") - response = await comm.get_response() - await comm.wait() - - assert response["status"] == 500 - - (event,) = (item.payload for item in items if item.type == "event") - - (exception,) = event["exception"]["values"] - assert exception["type"] == "ZeroDivisionError" - - # Test that the ASGI middleware got set up correctly. Right now this needs - # to be installed manually (see myapp/asgi.py) - assert event["transaction"] == "/view-exc" - assert event["request"] == { - "cookies": {}, - "headers": {}, - "method": "GET", - "query_string": "test=query", - "url": "/view-exc", - } - - capture_message("hi") - event = items[-1].payload - else: - events = capture_events() - - if ( - sys.version_info < (3, 9) - and channels.__version__ < "4.0.0" - and django.VERSION >= (3, 0) - and django.VERSION < (4, 0) - ): - # We emit a UserWarning for channels 2.x and 3.x on Python 3.8 and older - # because the async support was not really good back then and there is a known issue. - # See the TreadingIntegration for details. - with pytest.warns(UserWarning): - comm = HttpCommunicator(application, "GET", "/view-exc?test=query") - response = await comm.get_response() - await comm.wait() - else: - comm = HttpCommunicator(application, "GET", "/view-exc?test=query") - response = await comm.get_response() - await comm.wait() - - assert response["status"] == 500 - - (event,) = events - - (exception,) = event["exception"]["values"] - assert exception["type"] == "ZeroDivisionError" - - # Test that the ASGI middleware got set up correctly. Right now this needs - # to be installed manually (see myapp/asgi.py) - assert event["transaction"] == "/view-exc" - assert event["request"] == { - "cookies": {}, - "headers": {}, - "method": "GET", - "query_string": "test=query", - "url": "/view-exc", - } - - capture_message("hi") - event = events[-1] - - assert "request" not in event +# @pytest.mark.parametrize("application", APPS) +# @pytest.mark.asyncio +# @pytest.mark.skipif( +# django.VERSION < (3, 0), reason="Django ASGI support shipped in 3.0" +# ) +# @pytest.mark.parametrize("span_streaming", [True, False]) +# async def test_basic( +# sentry_init, +# capture_events, +# capture_items, +# application, +# span_streaming, +# ): +# sentry_init( +# integrations=[DjangoIntegration()], +# send_default_pii=True, +# _experiments={"trace_lifecycle": "stream" if span_streaming else "static"}, +# ) + +# import channels # type: ignore[import-not-found] + +# if span_streaming: +# items = capture_items("event") + +# if ( +# sys.version_info < (3, 9) +# and channels.__version__ < "4.0.0" +# and django.VERSION >= (3, 0) +# and django.VERSION < (4, 0) +# ): +# # We emit a UserWarning for channels 2.x and 3.x on Python 3.8 and older +# # because the async support was not really good back then and there is a known issue. +# # See the TreadingIntegration for details. +# with pytest.warns(UserWarning): +# comm = HttpCommunicator(application, "GET", "/view-exc?test=query") +# response = await comm.get_response() +# await comm.wait() +# else: +# comm = HttpCommunicator(application, "GET", "/view-exc?test=query") +# response = await comm.get_response() +# await comm.wait() + +# assert response["status"] == 500 + +# (event,) = (item.payload for item in items if item.type == "event") + +# (exception,) = event["exception"]["values"] +# assert exception["type"] == "ZeroDivisionError" + +# # Test that the ASGI middleware got set up correctly. Right now this needs +# # to be installed manually (see myapp/asgi.py) +# assert event["transaction"] == "/view-exc" +# assert event["request"] == { +# "cookies": {}, +# "headers": {}, +# "method": "GET", +# "query_string": "test=query", +# "url": "/view-exc", +# } + +# capture_message("hi") +# event = items[-1].payload +# else: +# events = capture_events() + +# if ( +# sys.version_info < (3, 9) +# and channels.__version__ < "4.0.0" +# and django.VERSION >= (3, 0) +# and django.VERSION < (4, 0) +# ): +# # We emit a UserWarning for channels 2.x and 3.x on Python 3.8 and older +# # because the async support was not really good back then and there is a known issue. +# # See the TreadingIntegration for details. +# with pytest.warns(UserWarning): +# comm = HttpCommunicator(application, "GET", "/view-exc?test=query") +# response = await comm.get_response() +# await comm.wait() +# else: +# comm = HttpCommunicator(application, "GET", "/view-exc?test=query") +# response = await comm.get_response() +# await comm.wait() + +# assert response["status"] == 500 + +# (event,) = events + +# (exception,) = event["exception"]["values"] +# assert exception["type"] == "ZeroDivisionError" + +# # Test that the ASGI middleware got set up correctly. Right now this needs +# # to be installed manually (see myapp/asgi.py) +# assert event["transaction"] == "/view-exc" +# assert event["request"] == { +# "cookies": {}, +# "headers": {}, +# "method": "GET", +# "query_string": "test=query", +# "url": "/view-exc", +# } + +# capture_message("hi") +# event = events[-1] + +# assert "request" not in event @pytest.mark.parametrize("application", APPS) From 317eb2228527114de0fed60f8d6715e356923478 Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Tue, 26 May 2026 13:34:53 +0200 Subject: [PATCH 3/3] empty commit