d4a1a5c2de
1. 替换所有旧的main函数测试逻辑,统一使用pyflowx的CliRunner和run方法进行测试 2. 重构测试类命名,将零散测试合并为TaskSpec验证测试 3. 优化测试用例结构,移除冗余的pytest依赖导入和旧版测试代码 4. 更新文件夹备份、压缩等模块的测试逻辑,适配新的工具函数实现
45 lines
1.5 KiB
Python
45 lines
1.5 KiB
Python
"""Tests for cli.clearscreen module."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
import pyflowx as px
|
|
from pyflowx.cli import clearscreen
|
|
from pyflowx.conditions import Constants
|
|
|
|
|
|
# ---------------------------------------------------------------------- #
|
|
# clear_screen
|
|
# ---------------------------------------------------------------------- #
|
|
class TestClearScreen:
|
|
"""Test clear_screen function."""
|
|
|
|
def test_clear_screen_windows(self) -> None:
|
|
"""Should clear screen on Windows."""
|
|
if Constants.IS_WINDOWS:
|
|
with patch("subprocess.run") as mock_run:
|
|
mock_run.return_value = MagicMock(returncode=0)
|
|
clearscreen.clear_screen()
|
|
assert mock_run.called
|
|
|
|
def test_clear_screen_linux(self) -> None:
|
|
"""Should clear screen on Linux."""
|
|
with patch.object(Constants, "IS_WINDOWS", False), patch("subprocess.run") as mock_run:
|
|
mock_run.return_value = MagicMock(returncode=0)
|
|
clearscreen.clear_screen()
|
|
assert mock_run.called
|
|
|
|
|
|
# ---------------------------------------------------------------------- #
|
|
# main function
|
|
# ---------------------------------------------------------------------- #
|
|
class TestMain:
|
|
"""Test main function."""
|
|
|
|
def test_main_creates_graph_and_runs(self) -> None:
|
|
"""main() should create a Graph and run it."""
|
|
with patch.object(px, "run") as mock_run:
|
|
clearscreen.main()
|
|
assert mock_run.called
|