Files
iAOP/core/inference-backend/tests/_bootstrap.py
T

17 lines
639 B
Python
Raw 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/inference-backend` 以包名 `inference_backend` 挂载到 sys.modules。
目录名 `inference-backend` 含连字符,无法直接以包名 import;挂载后模块内相对导入
(`from inference_backend.base import ...`)在 unittest 发现机制下可正常解析。
"""
import os
import sys
import types
BACKEND_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, BACKEND_DIR)
if "inference_backend" not in sys.modules:
pkg = types.ModuleType("inference_backend")
pkg.__path__ = [BACKEND_DIR]
sys.modules["inference_backend"] = pkg