Skip to content

refactor: replace patch logger with caplog in test_version.py#38029

Merged
asukaminato0721 merged 1 commit into
langgenius:mainfrom
EvanYao826:refactor/remove-patch-logger
Jun 26, 2026
Merged

refactor: replace patch logger with caplog in test_version.py#38029
asukaminato0721 merged 1 commit into
langgenius:mainfrom
EvanYao826:refactor/remove-patch-logger

Conversation

@EvanYao826

@EvanYao826 EvanYao826 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Replace unittest.mock.patch.object(logger, 'warning') with pytest's caplog fixture for capturing log output in test_http_error_fallback.

Changes

  • File: api/tests/unit_tests/controllers/console/test_version.py
  • Function: test_http_error_fallback
  • Added caplog: pytest.LogCaptureFixture parameter
  • Removed patch.object(version_module.logger, "warning", ) as log_warning
  • Added caplog.at_level(logging.WARNING, logger="controllers.console.version")
  • Changed log_warning.assert_called_once() to assert "Check update version error" in caplog.text

Related Issues

#37468

Testing

  • All 7 tests in test_version.py pass
  • Verified the modified test still correctly validates warning log output

Replace unittest.mock.patch.object(logger, 'warning') with pytest's
caplog fixture for capturing log output in test_http_error_fallback.

Fixes langgenius#37468
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. refactor labels Jun 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 51.40% 51.40% +0.00%
Strict coverage 50.92% 50.92% +0.00%
Typed symbols 30,655 30,656 +1
Untyped symbols 29,258 29,258 0
Modules 2929 2929 0

@asukaminato0721 asukaminato0721 added this pull request to the merge queue Jun 26, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jun 26, 2026
Merged via the queue into langgenius:main with commit 4fbfedd Jun 26, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer refactor size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants