Skip to content

Commit 8f4e555

Browse files
committed
更新测试case
1 parent 36baca3 commit 8f4e555

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

tests/test_jmcomic/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
import io
21
import platform
32
import unittest
43

54
# noinspection PyUnresolvedReferences
65
import jmcomic
76
from jmcomic import *
87

9-
# set encoding
10-
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, 'utf-8')
11-
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, 'utf-8')
8+
# 设置编码为 utf-8,使用 reconfigure() 而非替换 sys.stdout 对象
9+
# 直接替换会破坏 pytest 的 I/O 捕获机制,导致 "I/O operation on closed file" 错误
10+
if hasattr(sys.stdout, 'reconfigure'):
11+
sys.stdout.reconfigure(encoding='utf-8')
12+
if hasattr(sys.stderr, 'reconfigure'):
13+
sys.stderr.reconfigure(encoding='utf-8')
1214
# 获取项目根目录
1315
project_dir = os.path.abspath(os.path.dirname(__file__) + '/../..')
1416
os.chdir(project_dir)

tests/test_jmcomic/test_jm_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def search_and_test(expected_result, params):
186186
cases = {
187187
152637: {
188188
'search_query': '无修正',
189-
'order_by': JmMagicConstants.ORDER_BY_LIKE,
189+
'order_by': JmMagicConstants.ORDER_BY_VIEW,
190190
'time': JmMagicConstants.TIME_ALL,
191191
},
192192
147643: {

0 commit comments

Comments
 (0)