Skip to content

Commit 9e4d74c

Browse files
committed
fix: 解决 PR#528 的 review 问题
修复内容: 1. [稳定性提升] 为 CLI 终端探测的 subprocess 添加 timeout=10,防止测试机环境阻塞引发挂起 2. [问题捕获精度] 将底层极为宽泛的 Exception 拦截更改为 OSError,并独立捕获 TimeoutExpired
1 parent 5f2b5f1 commit 9e4d74c

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

tests/test_jmcomic/test_jm_cli.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,18 @@ def test_entry_points_installed(self):
5454
)
5555

5656
try:
57-
subprocess.run([cmd, "--help"], capture_output=True, text=True, check=True)
57+
subprocess.run(
58+
[cmd, "--help"],
59+
capture_output=True,
60+
text=True,
61+
check=True,
62+
timeout=10,
63+
)
64+
except subprocess.TimeoutExpired:
65+
self.fail(f"Command '{cmd} --help' timed out execution.")
5866
except subprocess.CalledProcessError as e:
5967
self.fail(f"Command '{cmd} --help' failed with exit code {e.returncode}. Stderr: {e.stderr.strip()}")
60-
except Exception as e:
68+
except OSError as e:
6169
self.fail(f"Failed to execute command '{cmd}': {e}")
6270

6371
# -- extract_album_id --

0 commit comments

Comments
 (0)