robust test suite for local dev (real PySide6 + non-UTF-8 Windows)#262
Open
Mizushima-Mihane wants to merge 3 commits into
Open
robust test suite for local dev (real PySide6 + non-UTF-8 Windows)#262Mizushima-Mihane wants to merge 3 commits into
Mizushima-Mihane wants to merge 3 commits into
Conversation
test_chat_history planted MagicMock stubs for PySide6 into sys.modules unconditionally at import time. On machines where PySide6 is installed but not yet imported, setdefault() installed the Mocks anyway and leaked them into every other test module in the same pytest process, breaking real QtCore/QtGui imports (QThread metaclass conflict) and causing 8 collection errors when the full suite runs. Guard the fakes behind `try: import PySide6 / except ImportError` so a real install is never clobbered. CI (no PySide6) still gets the fakes.
…-8 locales test_desktop_core_runtime_check_does_not_import_optional_packages and test_ui_update_manager_import_does_not_require_cv2 capture a subprocess with encoding="utf-8". On a non-UTF-8 (e.g. Chinese CP936) Windows locale the child can emit GBK bytes in localized OS error strings, which crashed the UTF-8 reader thread and left result.stdout as None -> 'NoneType' object has no attribute 'strip'. Add errors="replace" so decoding can't crash. The asserted JSON is printed with ensure_ascii=True, so it is unaffected.
|
ℹ️ PR 快照已变化或关闭,本次旧快照审查已安全取消。新提交会由新的 webhook 任务审查。 |
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
Two independent, test-only fixes that let the suite pass in a full local dev
environment (Windows, PySide6 installed, non-UTF-8 / CP936 locale). Both only
fail outside CI, so CI stayed green while local
pytest/ the pre-push hookwent red.
1. test_chat_history clobbered a real PySide6 install
test/unit/core/test_chat_history.pyfaked PySide6/QtWidgets/QtCore intosys.modulesunconditionally viasetdefault(). That only checks whether themodule is already imported, not installable — so on a machine with PySide6
installed but not yet imported, the mocks were planted and leaked into every
other test module, breaking real QtCore/QtGui imports
(
QThreadDagNode(DagNode, QThread)→ metaclass conflict) → 8 collection errors.Fix: only fake PySide6 when it genuinely can't be imported.
2. runtime-check subprocess decoding crashed on non-UTF-8 output
test_desktop_core_runtime_check_...andtest_ui_update_manager_import_does_not_require_cv2capture a subprocess with
encoding="utf-8". On a CP936 Windows box the childemits GBK bytes in localized OS error strings, crashing the UTF-8 reader thread
and leaving
result.stdoutas None →'NoneType'.strip().Fix: add
errors="replace"; the asserted JSON isensure_ascii=Trueso it's unaffected.Testing
pytest on Windows / Python 3.12 / PySide6 6.11.1: 1467 passed, 10 skipped
(previously 8 collection errors + 1 failure locally; CI unaffected).
📋 本次全部落定