Skip to content

Commit 242777b

Browse files
Fix issue with synthetic_test
1 parent ab3d715 commit 242777b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -978,6 +978,9 @@ async def test_user_agent_synthetic_test_detection(self):
978978
# Test each user agent case separately to avoid span accumulation
979979
for user_agent in test_cases:
980980
with self.subTest(user_agent=user_agent):
981+
# Reinitialize test state for each iteration to avoid state pollution
982+
self.setUp()
983+
981984
# Clear headers first
982985
self.scope["headers"] = []
983986

@@ -1001,9 +1004,6 @@ def update_expected_synthetic_test(
10011004
outputs, modifiers=[update_expected_synthetic_test]
10021005
)
10031006

1004-
# Clear spans after each test case to prevent accumulation
1005-
self.memory_exporter.clear()
1006-
10071007
async def test_user_agent_non_synthetic(self):
10081008
"""Test that normal user agents are not marked as synthetic"""
10091009
test_cases = [
@@ -1016,6 +1016,9 @@ async def test_user_agent_non_synthetic(self):
10161016
# Test each user agent case separately to avoid span accumulation
10171017
for user_agent in test_cases:
10181018
with self.subTest(user_agent=user_agent):
1019+
# Reinitialize test state for each iteration to avoid state pollution
1020+
self.setUp()
1021+
10191022
# Clear headers first
10201023
self.scope["headers"] = []
10211024

@@ -1039,9 +1042,6 @@ def update_expected_non_synthetic(
10391042
outputs, modifiers=[update_expected_non_synthetic]
10401043
)
10411044

1042-
# Clear spans after each test case to prevent accumulation
1043-
self.memory_exporter.clear()
1044-
10451045
async def test_user_agent_synthetic_new_semconv(self):
10461046
"""Test synthetic user agent detection with new semantic conventions"""
10471047
user_agent = b"Mozilla/5.0 (compatible; Googlebot/2.1)"

0 commit comments

Comments
 (0)