1818)
1919
2020
21- @pytest .fixture
22- def telemetry_system_reset ():
23- """Reset telemetry system state before each test."""
24- TelemetryClientFactory ._clients .clear ()
25- if TelemetryClientFactory ._executor :
26- TelemetryClientFactory ._executor .shutdown (wait = True )
27- TelemetryClientFactory ._executor = None
28- TelemetryClientFactory ._initialized = False
29- yield
30- TelemetryClientFactory ._clients .clear ()
31- if TelemetryClientFactory ._executor :
32- TelemetryClientFactory ._executor .shutdown (wait = True )
33- TelemetryClientFactory ._executor = None
34- TelemetryClientFactory ._initialized = False
35-
36-
3721@pytest .fixture
3822def mock_telemetry_client ():
3923 """Create a mock telemetry client for testing."""
@@ -200,7 +184,22 @@ def test_auth_flow_detection(self):
200184class TestTelemetryFactory :
201185 """Tests for TelemetryClientFactory lifecycle and management."""
202186
203- def test_client_lifecycle_flow (self , telemetry_system_reset ):
187+ @pytest .fixture (autouse = True )
188+ def telemetry_system_reset (self ):
189+ """Reset telemetry system state before each test."""
190+ TelemetryClientFactory ._clients .clear ()
191+ if TelemetryClientFactory ._executor :
192+ TelemetryClientFactory ._executor .shutdown (wait = True )
193+ TelemetryClientFactory ._executor = None
194+ TelemetryClientFactory ._initialized = False
195+ yield
196+ TelemetryClientFactory ._clients .clear ()
197+ if TelemetryClientFactory ._executor :
198+ TelemetryClientFactory ._executor .shutdown (wait = True )
199+ TelemetryClientFactory ._executor = None
200+ TelemetryClientFactory ._initialized = False
201+
202+ def test_client_lifecycle_flow (self ):
204203 """Test complete client lifecycle: initialize -> use -> close."""
205204 session_id_hex = "test-session"
206205 auth_provider = AccessTokenAuthProvider ("token" )
@@ -226,7 +225,7 @@ def test_client_lifecycle_flow(self, telemetry_system_reset):
226225 client = TelemetryClientFactory .get_telemetry_client (session_id_hex )
227226 assert isinstance (client , NoopTelemetryClient )
228227
229- def test_disabled_telemetry_flow (self , telemetry_system_reset ):
228+ def test_disabled_telemetry_flow (self ):
230229 """Test that disabled telemetry uses NoopTelemetryClient."""
231230 session_id_hex = "test-session"
232231
@@ -240,7 +239,7 @@ def test_disabled_telemetry_flow(self, telemetry_system_reset):
240239 client = TelemetryClientFactory .get_telemetry_client (session_id_hex )
241240 assert isinstance (client , NoopTelemetryClient )
242241
243- def test_factory_error_handling (self , telemetry_system_reset ):
242+ def test_factory_error_handling (self ):
244243 """Test that factory errors fall back to NoopTelemetryClient."""
245244 session_id = "test-session"
246245
@@ -258,7 +257,7 @@ def test_factory_error_handling(self, telemetry_system_reset):
258257 client = TelemetryClientFactory .get_telemetry_client (session_id )
259258 assert isinstance (client , NoopTelemetryClient )
260259
261- def test_factory_shutdown_flow (self , telemetry_system_reset ):
260+ def test_factory_shutdown_flow (self ):
262261 """Test factory shutdown when last client is removed."""
263262 session1 = "session-1"
264263 session2 = "session-2"
0 commit comments