18 lines
695 B
Python
18 lines
695 B
Python
# -*- coding: utf-8 -*-
|
||||
|
|
"""测试引导:把 `core/shift-handover` 以包名 `shift_handover` 挂载到 sys.modules。
|
|||
|
|
|
|||
|
|
目录名 `shift-handover` 含连字符,无法直接以包名 import;挂载后模块内相对导入
|
|||
|
|
(`from .handover import ...`)在 unittest 发现机制下可正常解析。
|
|||
|
|
(沿用 core/data-bus/tests/_bootstrap.py 的同一做法。)
|
|||
|
|
"""
|
|||
|
|
import os
|
|||
|
|
import sys
|
|||
|
|
import types
|
|||
|
|
|
|||
|
|
SHIFT_HANDOVER_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|||
|
|
sys.path.insert(0, SHIFT_HANDOVER_DIR)
|
|||
|
|
if "shift_handover" not in sys.modules:
|
|||
|
|
pkg = types.ModuleType("shift_handover")
|
|||
|
|
pkg.__path__ = [SHIFT_HANDOVER_DIR]
|
|||
|
|
sys.modules["shift_handover"] = pkg
|