Update unit testing

This commit is contained in:
SWHL committed 2022-11-17 19:51:12 +08:00
1 parent 5bc515d73e
commit ee70d8a6af
5 files changed
+139 -68

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
# -*- encoding: utf-8 -*-
# @Author: SWHL
# @Contact: liekkaskono@163.com
import importlib
import sys
from pathlib import Path
import yaml
class BaseModule(object):
def __init__(self, package_name: str = 'rapidocr_onnxruntime'):
self.package_name = package_name
self.root_dir = Path(__file__).resolve().parent.parent
sys.path.append(str(self.root_dir))
sys.path.append(str(self.root_dir / self.package_name))
def init_module(self, module_name: str, class_name: str = None):
if class_name is None:
module_part = importlib.import_module(f'{self.package_name}')
return module_part
module_part = importlib.import_module(f'{self.package_name}.{module_name}')
return getattr(module_part, class_name)
@staticmethod
def read_yaml(yaml_path: str):
with open(yaml_path, 'rb') as f:
data = yaml.load(f, Loader=yaml.Loader)
return data