Files
ykxmz/_build/patch_tests_after_uirewrite.py
T
xmz7891 b705216e4a ykxmz 1.5.0锛氫慨澶嶆墜琛ㄧ TLS 璇佷功鏍¢獙 + MTU 淇缃戠粶绋冲畾鎬?
琚帶绔?- 淇 MTU 闂锛氬す MSS + 璺緞 MTU 鎺㈡祴锛堝叕缃戝彲鐢ㄧ巼 48% -> 100%锛?- 澶嶇敤 HTTP 杩炴帴锛堝厤鎺夋瘡娆℃柊寤?TLS 鐨?30% 鎻℃墜澶辫触锛?- 姣忓垎閽熷洖澶存壘灞€鍩熺綉锛岃嚜鍔ㄥ垏鍥炲揩 400 鍊嶇殑璺緞
- 鐢婚潰蹇冭烦甯э細闈欐鏃剁渷娴侀噺锛屽鎴风浠嶇煡閬撴祦鏄椿鐨?- 閿佸睆鏃剁粰鍑哄彲鎿嶄綔鐨勬彁绀?
鎵嬭〃绔?- 鍐呯疆 GTS Root R4 / GlobalSign Root CA锛屼慨 SSLHandshakeException
- 杩炴帴閿欒缈昏瘧鎴愪汉璇濓紙璇佷功/鏃堕棿/瑙f瀽/瓒呮椂鍒嗗埆鎻愮ず锛?- 缁忎腑杞繛涓婂悗鐢ㄦ湇鍔″櫒鎶ョ殑鍦板潃鍒锋柊宸查厤瀵硅褰?- 鏂板灞€鍩熺綉杩炴帴椤甸潰銆佹湇鍔″櫒寤惰繜妫€娴?
鏈嶅姟鍣ㄧ
- 鏀寔 chunked 璇锋眰浣擄紙淇瘡 16 绉掍竴娆$殑杩炴帴閿欎贡涓庡ぇ闈㈢Н 502锛?- 缃戠粶璋冧紭鑴氭湰 net-tune.sh锛堝紑鏈鸿嚜鍔ㄥ簲鐢級
- 绠$悊椤碉細鎵归噺鍒犻櫎銆佺綉缁滀綋妫€銆佷笅杞藉尯
- 闅ч亾鏀?HTTP/2 + 鍙岃繛鎺?
鏂囨。
- 璁稿彲鍗忚 / 瀹夎鍓嶅繀璇?/ 瀹夎鍚庨』鐭ワ紙浣滆€咃細灏忛害瀛愶級
2026-10-06 19:01:05 +08:00

164 lines
5.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""界面重做之后的测试收尾。
* test_image_modes.py 改用 HeadlessUI(AgentUI 已删)
* test_indicator_visible.py 启动前先置 setup_done(否则会弹设置窗口)
* verify_all.ps1 去掉已删的测试阶段
"""
from __future__ import annotations
import sys
from pathlib import Path
ROOT = Path(r"C:\Users\shu\Desktop\deepseekagent\LanRemote")
TESTS = ROOT / "_tests"
# ---------------- 1. test_image_modes.py ----------------
IMAGE = TESTS / "test_image_modes.py"
IMAGE_FIXES = [
("from lanremote.ui import AgentUI # noqa: E402",
"from lanremote.headless import HeadlessUI # noqa: E402",
"改导入"),
(" agent = AgentUI(store)", " agent = HeadlessUI(store)", "改构造"),
(" try:\n agent.root.destroy()\n except tk.TclError:\n pass",
" try:\n agent.stop()\n except Exception:\n pass",
"改收尾"),
]
# ---------------- 2. test_indicator_visible.py ----------------
IND = TESTS / "test_indicator_visible.py"
IND_SEED = '''
def _seed_setup_done(data_dir):
"""这些测试测的是提示条,不是首次设置窗口。
界面重做之后,没设置过配对码就会弹设置窗口,会干扰测试,
所以先往数据目录里写一份 setup_done。
"""
import json as _json
data_dir = Path(data_dir)
data_dir.mkdir(parents=True, exist_ok=True)
settings = data_dir / "settings.json"
payload = {}
if settings.is_file():
try:
payload = _json.loads(settings.read_text(encoding="utf-8"))
except Exception:
payload = {}
payload["setup_done"] = True
settings.write_text(_json.dumps(payload, ensure_ascii=False, indent=2),
encoding="utf-8")
'''
def patch_file(path: Path, pairs) -> int:
if not path.is_file():
print(f" [跳过] {path.name} 不存在")
return 0
text = path.read_text(encoding="utf-8")
hits = 0
for old, new, tag in pairs:
if old not in text:
print(f" [跳过] {path.name} / {tag} —— 锚点没找到")
continue
text = text.replace(old, new, 1)
hits += 1
print(f" {path.name} / {tag}: OK")
if hits:
path.write_text(text, encoding="utf-8")
return hits
def main() -> int:
print("一、test_image_modes.py → HeadlessUI")
patch_file(IMAGE, IMAGE_FIXES)
print()
print("二、test_indicator_visible.py 预置 setup_done")
if IND.is_file():
text = IND.read_text(encoding="utf-8")
if "_seed_setup_done" in text:
print(" 已经加过")
else:
text = text.replace("def main() -> int:",
IND_SEED + "def main() -> int:", 1)
print(" 已插入辅助函数")
# 在启动子进程之前调用(找 Popen 前一行)
marker = " agent = subprocess.Popen("
if marker in text:
text = text.replace(
marker,
" _seed_setup_done(DATA_DIR)\n\n" + marker, 1)
print(" 已在启动前调用(用 DATA_DIR 变量名)")
IND.write_text(text, encoding="utf-8")
else:
print(" 文件不存在")
print()
print("三、verify_all.ps1 去掉已删的阶段")
va = TESTS / "verify_all.ps1"
raw = va.read_bytes()
bom = raw[:3] == b"\xef\xbb\xbf"
text = raw.decode("utf-8-sig")
# 删掉引用已删测试的整段
import re
for name in ("test_pc_gui.py", "test_simple_ui.py", "test_quit.py"):
pattern = re.compile(
r'\n# -+\s*\nBanner "[^"]*"\n(?:.*?\n)*?Record "[^"]*"[^\n]*\n',
re.M)
# 简单做法:把包含该文件名的 Banner 段整段删掉
lines = text.splitlines(keepends=True)
out = []
i = 0
removed = 0
while i < len(lines):
line = lines[i]
if name in line:
# 往上回溯,删掉这段的 Banner / Stop-Strays / 注释
while out and (out[-1].strip().startswith("#")
or out[-1].strip().startswith("Banner")
or out[-1].strip() == "Stop-Strays"
or out[-1].strip() == ""):
out.pop()
# 往下删到 Record 那一行
j = i
while j < len(lines) and 'Record "' not in lines[j]:
j += 1
i = j + 1 if j < len(lines) else len(lines)
removed += 1
continue
out.append(line)
i += 1
if removed:
text = "".join(out)
print(f" 已移除 {name} 相关阶段({removed} 处)")
data = text.encode("utf-8")
if bom:
data = b"\xef\xbb\xbf" + data
va.write_bytes(data)
print(" verify_all.ps1 已更新")
print()
print("四、语法检查")
import ast
ok = True
for path in (IMAGE, IND):
if not path.is_file():
continue
try:
ast.parse(path.read_text(encoding="utf-8"))
print(f" {path.name}: OK")
except SyntaxError as exc:
print(f" {path.name}: 语法错误 {exc}")
ok = False
return 0 if ok else 1
if __name__ == "__main__":
sys.exit(main())