Skip to content

Commit 91b8382

Browse files
committed
Clear feature flag context cache in teardown to fix test pollution
The FeatureFlagsContextFactory caches feature flag contexts per session, causing tests to share the same feature flag state. This resulted in the first test creating a context with telemetry enabled, and subsequent tests incorrectly reusing that enabled state even when they expected disabled.
1 parent 86d7828 commit 91b8382

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

tests/unit/test_telemetry.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,10 @@ class TestTelemetryFeatureFlag:
369369

370370
def teardown_method(self):
371371
"""Clean up telemetry factory state after each test to prevent test pollution."""
372+
from databricks.sql.common.feature_flag import FeatureFlagsContextFactory
373+
372374
TelemetryClientFactory._clients.clear()
375+
FeatureFlagsContextFactory._context_map.clear()
373376

374377
def _mock_ff_response(self, mock_http_request, enabled: bool):
375378
"""Helper method to mock feature flag response for unified HTTP client."""

0 commit comments

Comments
 (0)