17 lines
582 B
Python
17 lines
582 B
Python
# -*- coding: utf-8 -*-
|
||
"""测试引导:把 `core/llm-gateway` 以包名 `llm_gateway` 挂载到 sys.modules。
|
||
|
||
目录名 `llm-gateway` 含连字符,无法直接以包名 import;挂载后模块内相对导入
|
||
(`from .dlp import ...`)在 unittest 发现机制下可正常解析。
|
||
"""
|
||
import os
|
||
import sys
|
||
import types
|
||
|
||
LLM_GW_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||
sys.path.insert(0, LLM_GW_DIR)
|
||
if "llm_gateway" not in sys.modules:
|
||
pkg = types.ModuleType("llm_gateway")
|
||
pkg.__path__ = [LLM_GW_DIR]
|
||
sys.modules["llm_gateway"] = pkg
|