Skip to content

Commit c1a971f

Browse files
committed
Update test_asgi_middleware.py
1 parent be71c94 commit c1a971f

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

instrumentation/opentelemetry-instrumentation-asgi/tests/test_asgi_middleware.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -896,17 +896,17 @@ async def test_user_agent_synthetic_bot_detection(self):
896896
]
897897

898898
# Test each user agent case separately to avoid span accumulation
899-
for i, user_agent in enumerate(test_cases):
899+
for user_agent in test_cases:
900900
with self.subTest(user_agent=user_agent):
901901
# Clear headers first
902902
self.scope["headers"] = []
903903

904-
def update_expected_synthetic_bot(expected):
904+
def update_expected_synthetic_bot(
905+
expected, ua: bytes = user_agent
906+
):
905907
expected[3]["attributes"].update(
906908
{
907-
SpanAttributes.HTTP_USER_AGENT: user_agent.decode(
908-
"utf8"
909-
),
909+
SpanAttributes.HTTP_USER_AGENT: ua.decode("utf8"),
910910
USER_AGENT_SYNTHETIC_TYPE: "bot",
911911
}
912912
)
@@ -933,17 +933,17 @@ async def test_user_agent_synthetic_test_detection(self):
933933
]
934934

935935
# Test each user agent case separately to avoid span accumulation
936-
for i, user_agent in enumerate(test_cases):
936+
for user_agent in test_cases:
937937
with self.subTest(user_agent=user_agent):
938938
# Clear headers first
939939
self.scope["headers"] = []
940940

941-
def update_expected_synthetic_test(expected):
941+
def update_expected_synthetic_test(
942+
expected, ua: bytes = user_agent
943+
):
942944
expected[3]["attributes"].update(
943945
{
944-
SpanAttributes.HTTP_USER_AGENT: user_agent.decode(
945-
"utf8"
946-
),
946+
SpanAttributes.HTTP_USER_AGENT: ua.decode("utf8"),
947947
USER_AGENT_SYNTHETIC_TYPE: "test",
948948
}
949949
)
@@ -971,18 +971,18 @@ async def test_user_agent_non_synthetic(self):
971971
]
972972

973973
# Test each user agent case separately to avoid span accumulation
974-
for i, user_agent in enumerate(test_cases):
974+
for user_agent in test_cases:
975975
with self.subTest(user_agent=user_agent):
976976
# Clear headers first
977977
self.scope["headers"] = []
978978

979-
def update_expected_non_synthetic(expected):
979+
def update_expected_non_synthetic(
980+
expected, ua: bytes = user_agent
981+
):
980982
# Should only have the user agent, not synthetic type
981983
expected[3]["attributes"].update(
982984
{
983-
SpanAttributes.HTTP_USER_AGENT: user_agent.decode(
984-
"utf8"
985-
),
985+
SpanAttributes.HTTP_USER_AGENT: ua.decode("utf8"),
986986
}
987987
)
988988
return expected

0 commit comments

Comments
 (0)