15 lines
460 B
Python
15 lines
460 B
Python
import pytest
|
||
import sys
|
||
import os
|
||
|
||
# 自动添加项目根目录到路径(处理项目结构)
|
||
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
|
||
|
||
|
||
def run_this_test(test_file):
|
||
"""自定义函数:运行单个测试文件(类似pytest)"""
|
||
# 提取测试文件名(无扩展名)
|
||
test_name = os.path.splitext(os.path.basename(test_file))[0]
|
||
# 使用pytest运行(自动处理导入)
|
||
pytest.main([test_file, "-v"])
|