ModelTranslator: Quit/RunRizomUV 走超时通道防挂死 + _call 分支单测(审查修复)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
11d05fbeaa
commit
5de3c17155
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import unittest
|
||||
from unittest import mock
|
||||
|
||||
@@ -35,5 +36,19 @@ class TestFindRizomuv(unittest.TestCase):
|
||||
self.assertTrue(os.path.isfile(p), "注册表返回值应是真实 exe:%s" % p)
|
||||
|
||||
|
||||
class TestCall(unittest.TestCase):
|
||||
def test_timeout_raises(self):
|
||||
with self.assertRaises(ru.RizomError) as cm:
|
||||
ru._call("Slow", lambda p: time.sleep(1.0), None, timeout=0.05)
|
||||
self.assertIn("超时", str(cm.exception))
|
||||
|
||||
def test_error_dict_raises(self):
|
||||
with self.assertRaises(ru.RizomError):
|
||||
ru._call("Bad", lambda p: {"Error": {"Msg": "x", "Code": 1}}, {})
|
||||
|
||||
def test_normal_dict_passes_through(self):
|
||||
self.assertEqual(ru._call("Ok", lambda p: {"Data": 1}, {}), {"Data": 1})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user