test: 隔离单测中的站点原生资源 (#6452)

* test: isolate native site resources

* refactor(test): retain sites stub helper contract

* fix(test): preserve sites stub probe imports

---------

Co-authored-by: jxxghp <jxxghp@gmail.com>
This commit is contained in:
InfinityPacer
2026-08-25 16:26:46 +08:00
committed by GitHub
co-authored by jxxghp
parent f3622de82e
commit c727d9c9f1
10 changed files with 31 additions and 49 deletions
+1 -2
View File
@@ -14,8 +14,7 @@ def test_main_script_does_not_shadow_stdlib_platform(tmp_path):
(
"import runpy",
"import sys",
# CI 无 app.application.site.sites 二进制模块,先补垫片再执行 main.py(与 conftest 同源);
# 必须在篡改 sys.path / 摘除 platform 之前调用,避免真实依赖链受探针环境影响。
# 独立探针不经过 pytest 引导,先隔离站点原生制品,再改变模块搜索路径。
"from app.testing.bootstrap import ensure_sites_stub",
"ensure_sites_stub()",
f"sys.path.insert(0, {str(MAIN_PATH.parent)!r})",