@@ -172,6 +172,17 @@ def e2e_manager():
172172 from foundry_local_sdk .detail .core_interop import CoreInterop
173173 from foundry_local_sdk .foundry_local_manager import FoundryLocalManager
174174
175+ # Snapshot prior global state so we can restore it on teardown and avoid
176+ # cross-test contamination when this fixture runs in a shared session.
177+ prior_state = {
178+ "_initialized" : getattr (CoreInterop , "_initialized" , False ),
179+ "_flcore_library" : getattr (CoreInterop , "_flcore_library" , None ),
180+ "_ort_library" : getattr (CoreInterop , "_ort_library" , None ),
181+ "_genai_library" : getattr (CoreInterop , "_genai_library" , None ),
182+ }
183+ prior_manager_instance = getattr (FoundryLocalManager , "instance" , None )
184+ prior_ort_lib_path = os .environ .get ("ORT_LIB_PATH" )
185+
175186 CoreInterop ._initialized = False
176187 CoreInterop ._flcore_library = None
177188 CoreInterop ._ort_library = None
@@ -202,6 +213,18 @@ def e2e_manager():
202213 pass
203214 FoundryLocalManager .instance = None
204215
216+ # Restore prior global state
217+ CoreInterop ._initialized = prior_state ["_initialized" ]
218+ CoreInterop ._flcore_library = prior_state ["_flcore_library" ]
219+ CoreInterop ._ort_library = prior_state ["_ort_library" ]
220+ CoreInterop ._genai_library = prior_state ["_genai_library" ]
221+ FoundryLocalManager .instance = prior_manager_instance
222+
223+ if prior_ort_lib_path is None :
224+ os .environ .pop ("ORT_LIB_PATH" , None )
225+ else :
226+ os .environ ["ORT_LIB_PATH" ] = prior_ort_lib_path
227+
205228
206229class TestLiveAudioTranscriptionE2E :
207230 """E2E test for live audio transcription with synthetic PCM audio."""
0 commit comments