TDengine/test/new_test_framework/taostest/runner.py
WANG Xu 90bda4a857
refactor: test dir
Signed-off-by: WANG Xu <feici02@outlook.com>
2025-03-19 18:41:55 +08:00

40 lines
1.2 KiB
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.

"""
提供了运行测试用例的编程API 作为 taostest 命令行工具的补充。
通常一个 case 可以使用 taostest 命令,但是在 case 开发阶段需要能够在IDE中调试单个 Case 。 比如打断点单步执行。
此时可以使用 run_case 方法执行case。run_case 方法假设测试环境都已经setup好。
如果需要自定义 case 执行的 option, 可以使用 run_case_use_option 函数。
使用示例main.py
import taostest
taostest.runner.run_case("test_env.yaml", "query/case1.py")
"""
from .dataclass import CmdOption
from .frame import TaosTestFrame
#from .main import check_env
def run_case(env_file, case_file):
#env_ok = check_env()
#if not env_ok:
# print("set TEST_ROOT")
# return
opts = CmdOption()
opts.use = env_file
opts.cases = [case_file]
opts.keep = True
taos_test = TaosTestFrame(opts)
taos_test.start()
return taos_test
def run_case_use_option(opt: CmdOption):
#env_ok = check_env()
#if not env_ok:
# print("set TEST_ROOT")
# return
if opt is None or not isinstance(opt, CmdOption):
print("wrong opt")
return
taos_test = TaosTestFrame(opt)
taos_test.start()
return taos_test