fix(tests): resolve pre-existing test suite failures from missing mocks and env pollution - #2625
Closed
teyrebaz33 wants to merge 1 commit into
Closed
teyrebaz33 wants to merge 1 commit into
teyrebaz33 wants to merge 1 commit into
Conversation
…ks and env pollution Five test classes were failing on every CI run due to missing optional dependency mocks and test environment state pollution: - TestParallelClientConfig: 'parallel' module not installed; added sys.modules mock with FakeParallel class so isinstance() checks pass - TestTranscribeLocal / TestTranscribeLocalExtended: 'faster_whisper' module not installed; added sys.modules mock in setup_method with teardown cleanup to prevent state leakage between tests - TestGatewayWebSocket.test_event_received_and_forwarded: adapter created without watch_all=True so all state_changed events were dropped by the domain filter; fixed by passing watch_all=True - TestGetProvider.test_explicit_openai_no_key_returns_none: test pollution from earlier tests leaving OPENAI_API_KEY in the process environment; fixed by patching _resolve_openai_api_key directly instead of relying on env var deletion - TestDelegationCredentialResolution.test_direct_endpoint: OPENAI_API_KEY left in environment by earlier tests; fixed by including it in the patch.dict scope
Collaborator
|
Thanks for the contribution @teyrebaz33 — appreciate you taking the time to dig into these. Closing as a no-op against current
A few specifics:
If you hit a real test failure on current |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Five test classes were failing on every CI run. None of these failures were caused by the tests themselves being wrong — they were infrastructure issues: missing optional dependency mocks and test environment state pollution from earlier tests.
Root causes and fixes
TestParallelClientConfig(tests/tools/test_web_tools_config.py): Theparallelpackage is an optional dependency not installed in the test environment.from parallel import ParallelraisedModuleNotFoundError. Fixed by injecting asys.modulesmock with aFakeParallelclass soisinstance()checks pass correctly.TestTranscribeLocal/TestTranscribeLocalExtended(tests/tools/test_transcription.py,tests/tools/test_transcription_tools.py):faster_whisperis not installed in the test environment. Fixed by injecting asys.modulesmock insetup_methodwith cleanup inteardown_methodto prevent state leakage between tests.TestGatewayWebSocket.test_event_received_and_forwarded(tests/integration/test_ha_integration.py): The adapter was created withoutwatch_all=True, so allstate_changedevents were silently dropped by the domain filter. Fixed by passingwatch_all=Trueto_adapter_for().TestGetProvider.test_explicit_openai_no_key_returns_none(tests/tools/test_transcription.py): Test environment pollution — earlier tests leftOPENAI_API_KEYset in the process environment.monkeypatch.delenvonly removedVOICE_TOOLS_OPENAI_KEYbut_resolve_openai_api_key()also checksOPENAI_API_KEY. Fixed by patching_resolve_openai_api_keydirectly so the test is not sensitive to process-level env state.TestDelegationCredentialResolution.test_direct_endpoint(tests/tools/test_delegate.py): Same env pollution pattern —OPENAI_API_KEYwas set by an earlier test. Fixed by includingOPENAI_API_KEY: ""in thepatch.dictscope so the test controls its own environment.Verification
All 5 previously-failing test classes now pass. Full test suite: 5808 passed, 0 failed (excluding pre-existing ignores).