refactor(tests): replace logger mocks with caplog in trace provider tests#38569
Merged
asukaminato0721 merged 1 commit intoJul 9, 2026
Merged
Conversation
…ests (langgenius#37468) Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Pyrefly Type Coverage
|
Contributor
Author
|
Marking this ready for review — all tests, style, and type checks are green. Note on the "Validate PR title" check: the initial run failed due to a CI runner timeout (job hung for exactly 10m with no steps executed). A subsequent run of the same check passed: https://github.com/langgenius/dify/actions/runs/28951634957/job/85906573979. The stale failure entry can be ignored. |
asukaminato0721
approved these changes
Jul 9, 2026
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.
Summary
Part of #37468.
Replaces the remaining
logger_mock = MagicMock()+monkeypatch.setattr(..., "logger", ...)patterns with pytest'scaplogfixture in the trace provider tests, following the approach established in earlier PRs for this issue (e.g. #37922, #37890). These two files were found via code search after the files listed in the issue thread were already converted onmain:api/providers/trace/trace-aliyun/tests/unit_tests/aliyun_trace/test_aliyun_trace.py:test_get_project_url_errornow asserts oncaplog.textinstead oflogger_mock.info.assert_called().api/providers/trace/trace-tencent/tests/unit_tests/tencent_trace/test_client.py: removed theloggerMagicMock from thepatch_core_componentsfixture; the five tests that asserted onlogger.debug/logger.exceptioncalls now assert on captured log records, checking both level and message so the assertions are strictly stronger than before.Screenshots
N/A (test-only change)
Checklist
make lint && make type-check(backend) andcd web && pnpm exec vp staged(frontend) to appease the lint godsMade with Cursor
From Cursor