fix: 修复全量审查确认的 3 Critical + 5 Required,并修复 13 个腐化用例 #8
@@ -63,15 +63,18 @@ class TestEagerLoadCoverage:
|
|||||||
assert m, "Match 类未找到"
|
assert m, "Match 类未找到"
|
||||||
body = m.group(0)
|
body = m.group(0)
|
||||||
for rel in MATCH_RELATIONS:
|
for rel in MATCH_RELATIONS:
|
||||||
# 关系声明可能跨多行(home_team/away_team 都是),因此按
|
# 只取 relationship(...) 调用本身的括号内内容。
|
||||||
# 「从 `rel: Mapped` 到下一个单行注解声明之前」整段匹配。
|
# 注意: 不能把整段(含注释)做子串匹配 —— 关系声明下方的注释里
|
||||||
|
# 恰好也写着 lazy="selectin",会导致「删掉真实 kwarg 但测试仍绿」
|
||||||
|
# 的假阳性(已用变异测试证实: 移除 league 的 lazy 后断言依旧通过)。
|
||||||
m_rel = re.search(
|
m_rel = re.search(
|
||||||
rf"^[ \t]*{rel}: Mapped.*?(?=^[ \t]*\w+:[^\n]*Mapped|\Z)",
|
rf"^[ \t]*{rel}: Mapped.*?relationship\((.*?)\)[ \t]*$",
|
||||||
body, re.M | re.S,
|
body, re.M | re.S,
|
||||||
)
|
)
|
||||||
assert m_rel, f"Match.{rel} 未找到"
|
assert m_rel, f"Match.{rel} 未找到 relationship(...) 声明"
|
||||||
assert 'lazy="selectin"' in m_rel.group(0), (
|
call_args = m_rel.group(1)
|
||||||
f"Match.{rel} 未声明 lazy='selectin' —— 兜底缺失 (P0-2)"
|
assert 'lazy="selectin"' in call_args, (
|
||||||
|
f"Match.{rel} 的 relationship() 未声明 lazy='selectin' —— 兜底缺失 (P0-2)"
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_stats_relationship_is_lazy_select_by_design(self):
|
def test_stats_relationship_is_lazy_select_by_design(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user