Files

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