@@ -867,9 +867,9 @@ class LedgerAndApplicationTests(unittest.TestCase):
|
||||
self.assertEqual(version["route"], "local")
|
||||
self.assertIn("JWeBot 版本", version["text"])
|
||||
self.assertIn("kernel", version["text"])
|
||||
self.assertIn("最新版本:beta 1.0.0.1016", version["text"])
|
||||
self.assertIn("最新版本:beta 1.0.1.1016", version["text"])
|
||||
self.assertIn("更新时间:2026-10-16", version["text"])
|
||||
self.assertIn("更新摘要:Promote JWeBot", version["text"])
|
||||
self.assertIn("更新摘要:Limit RapidOCR", version["text"])
|
||||
self.assertEqual(debug["route"], "local")
|
||||
self.assertIn("调试埋点", debug["text"])
|
||||
self.assertEqual(balance["route"], "local")
|
||||
|
||||
@@ -4,6 +4,7 @@ import importlib.util
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import types
|
||||
import unittest
|
||||
from contextlib import nullcontext
|
||||
from datetime import datetime, timezone
|
||||
@@ -517,6 +518,56 @@ class GuiCoordinationTests(unittest.TestCase):
|
||||
|
||||
|
||||
class OcrFallbackTests(unittest.TestCase):
|
||||
def test_ocr_engine_limits_onnxruntime_threads_by_default(self):
|
||||
captured = {}
|
||||
|
||||
class FakeRapidOCR:
|
||||
def __init__(self, **kwargs):
|
||||
captured.update(kwargs)
|
||||
|
||||
fake_module = types.SimpleNamespace(RapidOCR=FakeRapidOCR)
|
||||
with mock.patch.dict(sys.modules, {"rapidocr": fake_module}), mock.patch.dict(
|
||||
MODULE.os.environ,
|
||||
{
|
||||
"WECHAT_OCR_ONNX_INTRA_OP_THREADS": "",
|
||||
"WECHAT_OCR_ONNX_INTER_OP_THREADS": "",
|
||||
},
|
||||
):
|
||||
MODULE.OcrEngine()
|
||||
|
||||
self.assertEqual(
|
||||
captured["params"],
|
||||
{
|
||||
"EngineConfig.onnxruntime.intra_op_num_threads": 1,
|
||||
"EngineConfig.onnxruntime.inter_op_num_threads": 1,
|
||||
},
|
||||
)
|
||||
|
||||
def test_ocr_engine_allows_thread_limit_overrides(self):
|
||||
captured = {}
|
||||
|
||||
class FakeRapidOCR:
|
||||
def __init__(self, **kwargs):
|
||||
captured.update(kwargs)
|
||||
|
||||
fake_module = types.SimpleNamespace(RapidOCR=FakeRapidOCR)
|
||||
with mock.patch.dict(sys.modules, {"rapidocr": fake_module}), mock.patch.dict(
|
||||
MODULE.os.environ,
|
||||
{
|
||||
"WECHAT_OCR_ONNX_INTRA_OP_THREADS": "2",
|
||||
"WECHAT_OCR_ONNX_INTER_OP_THREADS": "3",
|
||||
},
|
||||
):
|
||||
MODULE.OcrEngine()
|
||||
|
||||
self.assertEqual(
|
||||
captured["params"],
|
||||
{
|
||||
"EngineConfig.onnxruntime.intra_op_num_threads": 2,
|
||||
"EngineConfig.onnxruntime.inter_op_num_threads": 3,
|
||||
},
|
||||
)
|
||||
|
||||
def test_low_confidence_line_uses_detection_fallback(self):
|
||||
engine = MODULE.OcrEngine.__new__(MODULE.OcrEngine)
|
||||
bubble = MODULE.Bubble(50, 50, 132, 68, 5000)
|
||||
|
||||
Reference in New Issue
Block a user