Skip to content

Commit 74e34f2

Browse files
committed
fix: 更新ci测试用例
1 parent 0913448 commit 74e34f2

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

tests/test_cli.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,22 @@
22
import subprocess
33
import shutil
44
import pytest
5+
import sys
56

67

78
def run_command(cmd, input_text=None):
89
"""执行命令并返回结果"""
10+
encoding = "utf-8"
11+
912
if input_text:
1013
process = subprocess.Popen(
1114
cmd,
1215
shell=True,
1316
stdin=subprocess.PIPE,
1417
stdout=subprocess.PIPE,
1518
stderr=subprocess.PIPE,
16-
text=True,
19+
encoding=encoding,
20+
errors="replace",
1721
)
1822
stdout, stderr = process.communicate(input=input_text)
1923
returncode = process.returncode
@@ -22,11 +26,12 @@ def run_command(cmd, input_text=None):
2226
cmd,
2327
shell=True,
2428
capture_output=True,
25-
text=True,
29+
encoding=encoding,
30+
errors="replace",
2631
)
2732
returncode = result.returncode
28-
stdout = result.stdout
29-
stderr = result.stderr
33+
stdout = result.stdout or ""
34+
stderr = result.stderr or ""
3035
return returncode, stdout, stderr
3136

3237

0 commit comments

Comments
 (0)