复查修正: 卡包审计把带空格的键截在空格前
卡包按体系加分会加带空格的全名键(如「WARP快车谋杀案 复刻」), 审计从 AALC 日志取 「此次选择卡包关键词:X」时用 \S+, 截成「WARP快车谋杀案」, system_bonus 也对不上。 改成取到行尾; 补端到端用例(困难模式流血队选中复刻 WARP), 旧正则下该用例失败。 单测 704 个全过。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -232,9 +232,9 @@ class UpstreamSelectThemePackTest(unittest.TestCase):
|
|||||||
self.node = next(n for n in tree.body if isinstance(n, ast.FunctionDef) and n.name == 'select_theme_pack')
|
self.node = next(n for n in tree.body if isinstance(n, ast.FunctionDef) and n.name == 'select_theme_pack')
|
||||||
self.node.decorator_list = []
|
self.node.decorator_list = []
|
||||||
|
|
||||||
def play(self, cards, system, patched=True, audit=False, env=None):
|
def play(self, cards, system, patched=True, audit=False, env=None, hard=False):
|
||||||
positions = [(300 + 300 * i, 300) for i in range(len(cards))]
|
positions = [(300 + 300 * i, 300) for i in range(len(cards))]
|
||||||
weights = example_weights('theme_pack_list_cn')
|
weights = example_weights('theme_pack_list_cn', *(('theme_pack_list_hard_cn',) if hard else ()))
|
||||||
lookups = []
|
lookups = []
|
||||||
|
|
||||||
def find_language_text(zh, en, crop):
|
def find_language_text(zh, en, crop):
|
||||||
@@ -276,7 +276,7 @@ class UpstreamSelectThemePackTest(unittest.TestCase):
|
|||||||
if audit:
|
if audit:
|
||||||
ap.install_theme_pack_audit(log=self.lines.append)
|
ap.install_theme_pack_audit(log=self.lines.append)
|
||||||
mirror_mod.Mirror(system)
|
mirror_mod.Mirror(system)
|
||||||
mirror_mod.select_theme_pack(False, 4, 1, False)
|
mirror_mod.select_theme_pack(hard, 4, 1, False)
|
||||||
self.assertEqual(theme_list.get_effective_theme_pack_list(), weights, '权重表的原方法必须还原')
|
self.assertEqual(theme_list.get_effective_theme_pack_list(), weights, '权重表的原方法必须还原')
|
||||||
drag = auto.mouse_drag_down.call_args[0]
|
drag = auto.mouse_drag_down.call_args[0]
|
||||||
picked = cards[positions.index(drag)]
|
picked = cards[positions.index(drag)]
|
||||||
@@ -316,6 +316,14 @@ class UpstreamSelectThemePackTest(unittest.TestCase):
|
|||||||
# 普通模式: 复刻只在困难出现, 不算进「谋杀」这个键
|
# 普通模式: 复刻只在困难出现, 不算进「谋杀」这个键
|
||||||
self.assertEqual(kwargs['system_bonus'], {'packs': ['WARP快车谋杀案'], 'system': 'charge', 'from': -5, 'to': 1})
|
self.assertEqual(kwargs['system_bonus'], {'packs': ['WARP快车谋杀案'], 'system': 'charge', 'from': -5, 'to': 1})
|
||||||
|
|
||||||
|
def test_audit_keeps_a_key_with_a_space(self):
|
||||||
|
# 困难模式流血队: 复刻 WARP 专属流血 3 件, 用全名键「WARP快车谋杀案 复刻」; 审计不能截在空格前
|
||||||
|
picked, record, _ = self.play(['钉与锤', 'WARP快车谋杀案 复刻'], 'bleed', audit=True, hard=True)
|
||||||
|
self.assertEqual(picked, 'WARP快车谋杀案 复刻')
|
||||||
|
args, kwargs = record.call_args
|
||||||
|
self.assertEqual(args, ('theme_pack', 'WARP快车谋杀案 复刻', 'preferred'))
|
||||||
|
self.assertEqual(kwargs['system_bonus']['to'], 1)
|
||||||
|
|
||||||
def test_audit_without_bonus_has_no_system_field(self):
|
def test_audit_without_bonus_has_no_system_field(self):
|
||||||
_, record, _ = self.play(self.FLOOR4, 'bleed', audit=True)
|
_, record, _ = self.play(self.FLOOR4, 'bleed', audit=True)
|
||||||
self.assertNotIn('system_bonus', record.call_args[1])
|
self.assertNotIn('system_bonus', record.call_args[1])
|
||||||
|
|||||||
Reference in New Issue
Block a user