1- import sys
2-
31from collections import Counter
42
53import pytest
119from async_asgi_testclient import TestClient
1210
1311
14- minimum_python_36 = pytest .mark .skipif (
15- sys .version_info < (3 , 6 ), reason = "ASGI is only supported in Python >= 3.6"
16- )
17-
18-
1912@pytest .fixture
2013def asgi3_app ():
2114 async def app (scope , receive , send ):
@@ -133,7 +126,6 @@ async def app(scope, receive, send):
133126 return app
134127
135128
136- @minimum_python_36
137129def test_invalid_transaction_style (asgi3_app ):
138130 with pytest .raises (ValueError ) as exp :
139131 SentryAsgiMiddleware (asgi3_app , transaction_style = "URL" )
@@ -144,7 +136,6 @@ def test_invalid_transaction_style(asgi3_app):
144136 )
145137
146138
147- @minimum_python_36
148139@pytest .mark .asyncio
149140async def test_capture_transaction (
150141 sentry_init ,
@@ -176,7 +167,6 @@ async def test_capture_transaction(
176167 }
177168
178169
179- @minimum_python_36
180170@pytest .mark .asyncio
181171async def test_capture_transaction_with_error (
182172 sentry_init ,
@@ -214,7 +204,6 @@ async def test_capture_transaction_with_error(
214204 assert transaction_event ["request" ] == error_event ["request" ]
215205
216206
217- @minimum_python_36
218207@pytest .mark .asyncio
219208async def test_has_trace_if_performance_enabled (
220209 sentry_init ,
@@ -247,7 +236,6 @@ async def test_has_trace_if_performance_enabled(
247236 )
248237
249238
250- @minimum_python_36
251239@pytest .mark .asyncio
252240async def test_has_trace_if_performance_disabled (
253241 sentry_init ,
@@ -271,7 +259,6 @@ async def test_has_trace_if_performance_disabled(
271259 assert "trace_id" in error_event ["contexts" ]["trace" ]
272260
273261
274- @minimum_python_36
275262@pytest .mark .asyncio
276263async def test_trace_from_headers_if_performance_enabled (
277264 sentry_init ,
@@ -305,7 +292,6 @@ async def test_trace_from_headers_if_performance_enabled(
305292 assert transaction_event ["contexts" ]["trace" ]["trace_id" ] == trace_id
306293
307294
308- @minimum_python_36
309295@pytest .mark .asyncio
310296async def test_trace_from_headers_if_performance_disabled (
311297 sentry_init ,
@@ -334,7 +320,6 @@ async def test_trace_from_headers_if_performance_disabled(
334320 assert error_event ["contexts" ]["trace" ]["trace_id" ] == trace_id
335321
336322
337- @minimum_python_36
338323@pytest .mark .asyncio
339324async def test_websocket (sentry_init , asgi3_ws_app , capture_events , request ):
340325 sentry_init (debug = True , send_default_pii = True )
@@ -367,7 +352,6 @@ async def test_websocket(sentry_init, asgi3_ws_app, capture_events, request):
367352 assert exc ["value" ] == "Oh no"
368353
369354
370- @minimum_python_36
371355@pytest .mark .asyncio
372356async def test_auto_session_tracking_with_aggregates (
373357 sentry_init , asgi3_app , capture_envelopes
@@ -406,7 +390,6 @@ async def test_auto_session_tracking_with_aggregates(
406390 assert len (session_aggregates ) == 1
407391
408392
409- @minimum_python_36
410393@pytest .mark .parametrize (
411394 "url,transaction_style,expected_transaction,expected_source" ,
412395 [
@@ -470,7 +453,6 @@ async def __call__():
470453 pass
471454
472455
473- @minimum_python_36
474456def test_looks_like_asgi3 (asgi3_app ):
475457 # branch: inspect.isclass(app)
476458 assert _looks_like_asgi3 (MockAsgi3App )
@@ -487,7 +469,6 @@ def test_looks_like_asgi3(asgi3_app):
487469 assert not _looks_like_asgi3 (asgi2 )
488470
489471
490- @minimum_python_36
491472def test_get_ip_x_forwarded_for ():
492473 headers = [
493474 (b"x-forwarded-for" , b"8.8.8.8" ),
@@ -525,7 +506,6 @@ def test_get_ip_x_forwarded_for():
525506 assert ip == "5.5.5.5"
526507
527508
528- @minimum_python_36
529509def test_get_ip_x_real_ip ():
530510 headers = [
531511 (b"x-real-ip" , b"10.10.10.10" ),
@@ -550,7 +530,6 @@ def test_get_ip_x_real_ip():
550530 assert ip == "8.8.8.8"
551531
552532
553- @minimum_python_36
554533def test_get_ip ():
555534 # if now headers are provided the ip is taken from the client.
556535 headers = []
@@ -584,7 +563,6 @@ def test_get_ip():
584563 assert ip == "10.10.10.10"
585564
586565
587- @minimum_python_36
588566def test_get_headers ():
589567 headers = [
590568 (b"x-real-ip" , b"10.10.10.10" ),
@@ -602,7 +580,6 @@ def test_get_headers():
602580 }
603581
604582
605- @minimum_python_36
606583@pytest .mark .asyncio
607584@pytest .mark .parametrize (
608585 "request_url,transaction_style,expected_transaction_name,expected_transaction_source" ,
@@ -654,7 +631,6 @@ async def test_transaction_name(
654631 )
655632
656633
657- @minimum_python_36
658634@pytest .mark .asyncio
659635@pytest .mark .parametrize (
660636 "request_url, transaction_style,expected_transaction_name,expected_transaction_source" ,
0 commit comments