Skip to content

Commit 86d7828

Browse files
committed
Add teardown_method to clear telemetry factory state between tests
Without this cleanup, tests were sharing telemetry clients because they all used the same host key ("test"), causing test pollution. The first test would create an enabled client, and subsequent tests would reuse it even when they expected a disabled client.
1 parent 9026f37 commit 86d7828

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

tests/unit/test_telemetry.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,10 @@ def test_connection_failure_sends_correct_telemetry_payload(
367367
class TestTelemetryFeatureFlag:
368368
"""Tests the interaction between the telemetry feature flag and connection parameters."""
369369

370+
def teardown_method(self):
371+
"""Clean up telemetry factory state after each test to prevent test pollution."""
372+
TelemetryClientFactory._clients.clear()
373+
370374
def _mock_ff_response(self, mock_http_request, enabled: bool):
371375
"""Helper method to mock feature flag response for unified HTTP client."""
372376
mock_response = MagicMock()

0 commit comments

Comments
 (0)