Merge pull request #7050 from DDSRem-Dev/codex-comment-migration

docs: 统一全项目中文注释和结构化契约说明
This commit is contained in:
DDSRem
2026-10-17 19:26:29 +08:00
committed by GitHub
parent 3c7431b7da
commit 2de976f6b3
2345 changed files with 143990 additions and 61534 deletions

View File

@@ -1,4 +1,6 @@
"""共享测试引导工具的回归用例。"""
"""
共享测试引导工具的回归用例。
"""
from __future__ import annotations
import builtins
@@ -10,7 +12,9 @@ from app.testing import bootstrap
def test_ensure_sites_stub_replaces_loaded_dynamic_resource(monkeypatch):
"""隔离探针必须覆盖本机资源模块,保证 source-only CI 与开发机前提一致。"""
"""
隔离探针必须覆盖本机资源模块,保证 source-only CI 与开发机前提一致。
"""
real_module = types.ModuleType("app.application.site.sites")
real_module.SitesHelper = object
monkeypatch.setitem(sys.modules, "app.application.site.sites", real_module)
@@ -23,7 +27,9 @@ def test_ensure_sites_stub_replaces_loaded_dynamic_resource(monkeypatch):
def test_prepare_backend_replaces_loaded_dynamic_resource(monkeypatch):
"""普通测试引导必须隔离源码目录中已存在的站点原生制品。"""
"""
普通测试引导必须隔离源码目录中已存在的站点原生制品。
"""
real_module = types.ModuleType("app.application.site.sites")
real_module.SitesHelper = object
monkeypatch.setitem(sys.modules, "app.application.site.sites", real_module)
@@ -36,18 +42,24 @@ def test_prepare_backend_replaces_loaded_dynamic_resource(monkeypatch):
def test_isolate_config_cleanup_uses_loaded_db_module_without_late_import(monkeypatch):
"""清理回调只读取已加载模块,避免解释器关停期触发二次导入。"""
"""
清理回调只读取已加载模块,避免解释器关停期触发二次导入。
"""
captured = {}
import_calls = []
def fake_import(name, *args, **kwargs):
"""记录清理回调是否试图重新导入数据库模块。"""
"""
记录清理回调是否试图重新导入数据库模块。
"""
if name == "app.db":
import_calls.append(name)
return original_import(name, *args, **kwargs)
def fake_register(func):
"""截获 atexit 回调,便于直接验证清理行为。"""
"""
截获 atexit 回调,便于直接验证清理行为。
"""
captured["cleanup"] = func
monkeypatch.setattr(bootstrap, "_isolated_config_dir", None)
@@ -66,17 +78,23 @@ def test_isolate_config_cleanup_uses_loaded_db_module_without_late_import(monkey
def test_mark_plugin_generation_prefers_pathlib_item_path():
"""pytest 新版 item.path 可独立驱动 v1/v2 marker 标记。"""
"""
pytest 新版 item.path 可独立驱动 v1/v2 marker 标记。
"""
class FakeItem:
"""只暴露 pytest 7+ 的 path 属性,模拟新版收集对象。"""
"""
只暴露 pytest 7+ 的 path 属性,模拟新版收集对象。
"""
def __init__(self, value: str):
self.path = Path(value)
self.markers = []
def add_marker(self, marker):
"""记录被添加的 marker。"""
"""
记录被添加的 marker。
"""
self.markers.append(marker)
pytest_module = types.SimpleNamespace(mark=types.SimpleNamespace(v1="v1", v2="v2"))