fix: mock vision client in exc_info test to fix CI failure#804
Closed
teyrebaz33 wants to merge 3 commits into
Closed
fix: mock vision client in exc_info test to fix CI failure#804teyrebaz33 wants to merge 3 commits into
teyrebaz33 wants to merge 3 commits into
Conversation
Move caplog.at_level context manager before await calls and call caplog.handler.setLevel() explicitly so log records with exc_info are captured correctly in async tests on Python 3.11. The previous test structure had caplog.at_level wrapping an await expression, which caused exc_info to not be captured on Python 3.11 due to differences in async logging propagation between 3.11 and 3.12.
…1 compat caplog does not reliably capture log records in async tests on Python 3.11. Replace caplog with patch.object on the module logger and assert exc_info=True was passed directly to the error call.
Without these mocks the function returns early when no vision client is configured (CI environment), so logger.error is never called and the assertion fails.
This was referenced Mar 10, 2026
Contributor
|
Thanks for identifying this CI issue! However, this fix is already on main — commit 0229e6b applied the same fix (mocking Appreciate you taking the time to dig into the root cause though — your analysis of the early-return guard was spot on. 🙏 |
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
test_analysis_error_logs_exc_infowas failing in CI with:assert mock_error.called
AssertionError: assert False
Root Cause
In CI environments where no vision API key is configured,
_aux_async_clientisNoneandDEFAULT_VISION_MODELisNone. The function returns early before reaching the download/error path, sologger.erroris never called and the assertion fails.Fix
Mock
_aux_async_clientandDEFAULT_VISION_MODELin the test so the function proceeds past the early-return guard and actually reaches the error handling path.Testing
All 42 vision tool tests pass locally.