@@ -48,8 +48,11 @@ async def app(scope, receive, send):
48
48
49
49
@pytest .fixture
50
50
def asgi3_app_with_error ():
51
+ async def send_with_error (event ):
52
+ 1 / 0
53
+
51
54
async def app (scope , receive , send ):
52
- await send (
55
+ await send_with_error (
53
56
{
54
57
"type" : "http.response.start" ,
55
58
"status" : 200 ,
@@ -58,10 +61,7 @@ async def app(scope, receive, send):
58
61
],
59
62
}
60
63
)
61
-
62
- 1 / 0
63
-
64
- await send (
64
+ await send_with_error (
65
65
{
66
66
"type" : "http.response.body" ,
67
67
"body" : b"Hello, world!" ,
@@ -167,9 +167,9 @@ async def test_capture_transaction_with_error(
167
167
sentry_init (send_default_pii = True , traces_sample_rate = 1.0 )
168
168
app = SentryAsgiMiddleware (asgi3_app_with_error )
169
169
170
+ events = capture_events ()
170
171
with pytest .raises (ZeroDivisionError ):
171
172
async with TestClient (app ) as client :
172
- events = capture_events ()
173
173
await client .get ("/" )
174
174
175
175
(error_event , transaction_event ) = events
@@ -423,7 +423,7 @@ async def test_transaction_style(
423
423
events = capture_events ()
424
424
await client .get (url )
425
425
426
- (_ , transaction_event ) = events
426
+ (transaction_event , ) = events
427
427
428
428
assert transaction_event ["transaction" ] == expected_transaction
429
429
assert transaction_event ["transaction_info" ] == {"source" : expected_source }
0 commit comments