fix(test): 修复Unit Tests收集失败 - dedup模块级mock污染sys.modules #917
Reference in New Issue
Block a user
Delete Branch "fix/ci-unit-tests-collection-906"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
问题
Unit Tests收集阶段5个文件报错:3个AttributeError: spec + 2个ImportError: cannot import name assert_auto_create_schema_allowed
根因
test_dedup_pure.py在模块级 mock 了整个worker_app包和packages.adapters.sqlalchemy_impl包,污染全局sys.modules。pytest 按字母顺序收集测试时,dedup_pure(d开头)先被收集,它的模块级 mock 导致后续测试文件导入这些包的子模块时失败。修复
packages.adapters.sqlalchemy_impl.session(真正触发数据库连接的元凶),不 mock 整个 sqlalchemy_impl 包__spec__=None,避免 Python 导入系统 AttributeError验证
fix #906
50b6126367to24b4c6f1a0🗑️ 预览环境已清理
PR #917 已关闭或合并,对应的预览环境已被清理。