first commit
This commit is contained in:
1 parent
d2b2284bd4
commit
92b1584aaa
10 files changed
+142
-13
No files matched your search
Binary file not shown.
@@ -0,0 +1,37 @@
|
||||
import os
|
||||
import pytest
|
||||
import logging
|
||||
|
||||
from src.ziniao import Ziniao
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def ziniao_instance():
|
||||
"""创建并返回一个Ziniao实例,可以被多个测试函数重复使用"""
|
||||
return Ziniao()
|
||||
|
||||
|
||||
def test_get_ziniao_exe_path(ziniao_instance):
|
||||
"""测试get_ziniao_exe_path方法是否返回合法的可执行文件路径"""
|
||||
exe_path = ziniao_instance.get_ziniao_exe_path()
|
||||
# 使用pytest的日志功能替代print
|
||||
logging.info(f"紫鸟EXE路径: {exe_path}")
|
||||
assert isinstance(exe_path, str)
|
||||
assert len(exe_path) > 0
|
||||
# 验证路径是否存在(如果此测试在未安装紫鸟的环境中可能会失败)
|
||||
assert os.path.exists(exe_path)
|
||||
|
||||
|
||||
def test_launch_ziniao(ziniao_instance):
|
||||
"""测试launch_ziniao方法是否能成功启动紫鸟"""
|
||||
try:
|
||||
ziniao_instance.launch_ziniao()
|
||||
logging.info("紫鸟启动成功")
|
||||
except Exception as e:
|
||||
pytest.fail(f"启动紫鸟失败: {e}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# 保留原来的手动测试代码,但仅在直接运行此文件时执行
|
||||
ziniao_instance = Ziniao()
|
||||
print(f"紫鸟EXE路径: {ziniao_instance.get_ziniao_exe_path()}")
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
Reference in new issue
Block a user