修复福袋详情OCR v2与调试日志

This commit is contained in:
Your Name committed 2026-06-03 01:22:13 +08:00
1 parent 2c6f024a24
commit 1d37d57c90
119 files changed
+5582 -767

No files matched your search

+44
View File
@@ -4,6 +4,7 @@
"""
from __future__ import annotations
import io
import logging
import pytest
@@ -236,3 +237,46 @@ class TestAdbCompat:
write_config(cur) # 写回原值,不改任何东西
except Exception as e:
pytest.fail(f"write_config 不应抛: {e}")
class TestRequestParsing:
def test_read_json_invalid_content_length_returns_empty(self):
from gui.web_gui_pkg.request_parsing import read_json
class _Dummy:
headers = {"Content-Length": "abc"}
rfile = io.BytesIO(b'{"x":1}')
assert read_json(_Dummy()) == {}
@pytest.mark.parametrize(
"exc_type",
[BrokenPipeError, ConnectionAbortedError, ConnectionResetError],
)
def test_send_json_ignores_client_disconnect(self, exc_type):
from gui.web_gui_pkg.request_parsing import send_json
class _Dummy:
def __init__(self):
self.wfile = self
self.status = None
self.headers = []
self.header_finished = False
def send_response(self, status):
self.status = status
def send_header(self, key, value):
self.headers.append((key, value))
def end_headers(self):
self.header_finished = True
def write(self, _data):
raise exc_type("client disconnected")
dummy = _Dummy()
send_json(dummy, {"ok": True})
assert dummy.status == 200
assert dummy.header_finished is True