Files
StarAsh042 2689d2af5c test: 纳入 316 项测试
把纯逻辑、节点冒烟、加工脚本、跨进程去重与路径防护的用例一并入库;
同时解除 UNC 用例对固定安装路径的依赖。
2026-10-20 09:12:00 +08:00

26 lines
995 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""守卫测试:``ra_core`` 只能以包路径导入一次。
如果测试里同时写了 ``import ra_core``(顶层)与 ``ComfyUI_RollingArtist.ra_core``,
Python 会把同一份源码加载成两个不同模块,连带出现两份进程级单例:
两个数据库连接指向同一个文件,测试之间会互相抢写锁、出现难以排查的超时。
这里把它钉死,避免以后有人顺手改导入方式。
"""
import sys
import ComfyUI_RollingArtist.ra_core.db as packaged_db
def test_ra_core_is_not_imported_as_top_level_module():
assert "ra_core" not in sys.modules, (
"检测到顶层导入 ra_core;请统一改用 ComfyUI_RollingArtist.ra_core,"
"否则会出现两份单例(数据库连接互相抢锁)"
)
assert "ra_core.db" not in sys.modules
def test_node_and_core_share_the_same_module_instance():
from ComfyUI_RollingArtist import RollingArtist as node_module
assert node_module.get_db is packaged_db.get_db