修复运行日志复核发现的任务控制与结果误判
This commit is contained in:
@@ -131,11 +131,7 @@ class ReadEnkephalinTest(QuietLogMixin, unittest.TestCase):
|
|||||||
|
|
||||||
|
|
||||||
class LunacyReadTest(QuietLogMixin, unittest.TestCase):
|
class LunacyReadTest(QuietLogMixin, unittest.TestCase):
|
||||||
"""狂气数字是像素艺术字, OCR 会误读(实测 6636 读成 9699)。
|
"""狂气数字会有多种 OCR 误读; 同帧取数、多帧投票仍只提供核查线索。"""
|
||||||
|
|
||||||
所以脚本不对绝对值下结论, 只做**前后相对比对**: 同一个画面同一套字体,
|
|
||||||
误读方式一致, 两次读数不同就说明数字真的变了。
|
|
||||||
"""
|
|
||||||
|
|
||||||
def _frames(self, values):
|
def _frames(self, values):
|
||||||
seq = list(values)
|
seq = list(values)
|
||||||
@@ -156,6 +152,25 @@ class LunacyReadTest(QuietLogMixin, unittest.TestCase):
|
|||||||
mock.patch.object(cm.time, 'sleep', lambda s: None):
|
mock.patch.object(cm.time, 'sleep', lambda s: None):
|
||||||
self.assertIsNone(cm.read_lunacy())
|
self.assertIsNone(cm.read_lunacy())
|
||||||
|
|
||||||
|
def test_first_pair_does_not_override_later_majority(self):
|
||||||
|
with mock.patch.object(cm, 'items', self._frames([8859, 8859, 6388, 6388, 6388])), \
|
||||||
|
mock.patch.object(cm.time, 'sleep'):
|
||||||
|
self.assertEqual(cm.read_lunacy(), 6388)
|
||||||
|
|
||||||
|
def test_label_and_balance_must_come_from_the_same_frame(self):
|
||||||
|
# 数字和标签从未同时出现, 跨帧拼接会伪造一个有效读数。
|
||||||
|
frames = [[{'text': '9999', 'x': 664, 'y': 823}],
|
||||||
|
[{'text': 'LUNACY', 'x': 670, 'y': 795}]] * 5
|
||||||
|
with mock.patch.object(cm, 'items', side_effect=frames) as sample, \
|
||||||
|
mock.patch.object(cm.time, 'sleep'):
|
||||||
|
self.assertIsNone(cm.read_lunacy())
|
||||||
|
self.assertEqual(sample.call_count, 5)
|
||||||
|
|
||||||
|
def test_tied_readings_are_unknown(self):
|
||||||
|
with mock.patch.object(cm, 'items', self._frames([8859, 8859, 6388, 6388, 1000])), \
|
||||||
|
mock.patch.object(cm.time, 'sleep'):
|
||||||
|
self.assertIsNone(cm.read_lunacy())
|
||||||
|
|
||||||
|
|
||||||
class EnkephalinGateTest(QuietLogMixin, unittest.TestCase):
|
class EnkephalinGateTest(QuietLogMixin, unittest.TestCase):
|
||||||
"""体力读数是"要不要合成"的闸门, 读不到时不能贸然去点合成。
|
"""体力读数是"要不要合成"的闸门, 读不到时不能贸然去点合成。
|
||||||
@@ -305,6 +320,10 @@ class LunacyVerdictTest(unittest.TestCase):
|
|||||||
suspicious2, _ = cm.lunacy_verdict(4000, 3000)
|
suspicious2, _ = cm.lunacy_verdict(4000, 3000)
|
||||||
self.assertTrue(suspicious2)
|
self.assertTrue(suspicious2)
|
||||||
|
|
||||||
|
def test_new_balance_must_not_be_silently_folded_into_old_readings(self):
|
||||||
|
suspicious, _ = cm.lunacy_verdict(10000, 6636)
|
||||||
|
self.assertTrue(suspicious)
|
||||||
|
|
||||||
|
|
||||||
class LunacyFalseAlarmTest(QuietLogMixin, unittest.TestCase):
|
class LunacyFalseAlarmTest(QuietLogMixin, unittest.TestCase):
|
||||||
"""整轮跑下来: 已知读法抖动不该让这一轮 FAIL。"""
|
"""整轮跑下来: 已知读法抖动不该让这一轮 FAIL。"""
|
||||||
@@ -388,6 +407,13 @@ class ConvertAttemptVerifiedTest(QuietLogMixin, unittest.TestCase):
|
|||||||
self.assertFalse(ok)
|
self.assertFalse(ok)
|
||||||
self.assertIn('没变', info)
|
self.assertIn('没变', info)
|
||||||
|
|
||||||
|
def test_decrease_is_not_a_successful_negative_conversion(self):
|
||||||
|
seq = [35]
|
||||||
|
ok, info, got = self._attempt(lambda: seq.pop(0) if seq else 33)
|
||||||
|
self.assertFalse(ok)
|
||||||
|
self.assertEqual(got, 0)
|
||||||
|
self.assertIn('读数下降', info)
|
||||||
|
|
||||||
def test_unchanged_message_does_not_blame_enkephalin(self):
|
def test_unchanged_message_does_not_blame_enkephalin(self):
|
||||||
"""走到这一步时体力 >= 20 已经确认过, 所以"体力不足"不可能是原因。
|
"""走到这一步时体力 >= 20 已经确认过, 所以"体力不足"不可能是原因。
|
||||||
|
|
||||||
@@ -601,6 +627,14 @@ class CliRoutingTest(QuietLogMixin, unittest.TestCase):
|
|||||||
self.assertEqual(code, 0)
|
self.assertEqual(code, 0)
|
||||||
self.assertEqual(closed, [], '--keep-game 时不该关游戏')
|
self.assertEqual(closed, [], '--keep-game 时不该关游戏')
|
||||||
|
|
||||||
|
def test_a_skipped_run_does_not_reuse_previous_lunacy_result(self):
|
||||||
|
cm._result.update(lunacy_after=9699, lunacy_checked=True, converted=True)
|
||||||
|
code, _, _ = self._main([]) # 体力不足, 不合成也不做后读。
|
||||||
|
self.assertEqual(code, 0)
|
||||||
|
self.assertNotIn('lunacy_after', cm._result)
|
||||||
|
self.assertNotIn('lunacy_checked', cm._result)
|
||||||
|
self.assertFalse(cm._result['converted'])
|
||||||
|
|
||||||
def test_report_is_written_with_the_expected_fields(self):
|
def test_report_is_written_with_the_expected_fields(self):
|
||||||
"""报告字段要齐全 —— 值守就靠 lunacy_* 和 converted 那几项下结论。"""
|
"""报告字段要齐全 —— 值守就靠 lunacy_* 和 converted 那几项下结论。"""
|
||||||
import json
|
import json
|
||||||
|
|||||||
Reference in New Issue
Block a user