1 Star 0 Fork 2

凹凸曼打小怪兽/wenjian

forked from banzhuanxiaodoubi/wenjian 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
adapter.py 2.57 KB
一键复制 编辑 原始数据 按行查看 历史
banzhuanxiaodoubi 提交于 2022-06-02 10:33 . adapter
from abc import ABCMeta,abstractmethod
class Executor(metaclass=ABCMeta):
@abstractmethod
def deploy_env(self):
pass
@abstractmethod
def init_env(self):
pass
@abstractmethod
def get_case_code(self):
pass
@abstractmethod
def suite2cases_resolver(self):
pass
@abstractmethod
def run_all_cases(self):
pass
@abstractmethod
def run_suite(self):
pass
@abstractmethod
def run_case(self):
pass
class LogResolver(metaclass=ABCMeta):
@abstractmethod
def loads_logs(self, log_lines):
return log_lines
class Mugen:
def _executor(self):
return MugenExecutor()
class LTP:
def _executor(self):
return LtpExecutor()
class FrameWorkDict:
mugen = Mugen
ltp = LTP
class MugenExecutor:
def deploy_env(self):
pass
def init_env(self):
pass
def get_case_code(self):
pass
def suite2cases_resolver(self):
pass
def run_all_cases(self):
pass
def run_suite(self):
pass
def run_case(self):
print("mugen is ok")
class LtpExecutor:
def deploy_env(self):
pass
def init_env(self):
pass
def get_case_code(self):
pass
def suite2cases_resolver(self):
pass
def run_all_cases(self):
pass
def run_suite(self):
pass
def run_case(self):
print("ltp is ok ")
class LtpLogResolver:
def loads_logs(self, log_lines):
return log_lines
class MugenLogResolver:
def loads_logs(self, log_lines):
return log_lines
class ExecutorAdapter(Executor):
def __init__(self, executor):
self._executor=executor
def deploy_env(self):
self._executor.deploy_env()
def init_env(self):
self._executor.init_env()
def get_case_code(self):
self._executor.get_case_code()
def suite2cases_resolver(self):
self._executor.suite2cases_resolver()
def run_all_cases(self):
self._executor.run_all_cases()
def run_suite(self):
self._executor.run_suite()
def run_case(self):
self._executor.run_case()
# class LogResolverAdapt(LogResolver):
# def __init__(self, logresolver):
# self._logresolver=logresolver
class RunCaseHandler:
def __init__(self, framework):
self._framework = getattr(FrameWorkDict, framework)
def work(self):
self._executor = ExecutorAdapter(self._framework()._executor())
self._executor.run_case()
if __name__ == "__main__":
RunCaseHandler("ltp").work()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/concave-convex-manda/wenjian.git
git@gitee.com:concave-convex-manda/wenjian.git
concave-convex-manda
wenjian
wenjian
master

搜索帮助