59 lines
2.2 KiB
Python
59 lines
2.2 KiB
Python
"""T11 演示脚本冒烟测试:八步都出现、未实现处不伪装、工程与模型效果分列。"""
|
|||
|
|
|
||
|
|
import contextlib
|
||
|
|
import io
|
||
|
|
import sys
|
||
|
|
import unittest
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
SCRIPTS = Path(__file__).resolve().parent.parent / "scripts"
|
||
|
|
sys.path.insert(0, str(SCRIPTS))
|
||
|
|
|
||
|
|
import xingbang_prescreen_demo as demo # noqa: E402
|
||
|
|
|
||
|
|
|
||
|
|
class DemoScriptTests(unittest.TestCase):
|
||
|
|
def output(self) -> str:
|
||
|
|
buffer = io.StringIO()
|
||
|
|
with contextlib.redirect_stdout(buffer):
|
||
|
|
code = demo.main()
|
||
|
|
self.assertEqual(code, 0)
|
||
|
|
return buffer.getvalue()
|
||
|
|
|
||
|
|
def test_every_step_is_reported_with_its_real_status(self):
|
||
|
|
text = self.output()
|
||
|
|
for index, title, status, _ in demo.STEPS:
|
||
|
|
self.assertIn(f"{index}. [{status}] {title}", text)
|
||
|
|
|
||
|
|
def test_unimplemented_steps_say_why(self):
|
||
|
|
text = self.output()
|
||
|
|
self.assertIn("未实现", text)
|
||
|
|
self.assertIn("需要真实历史材料", text)
|
||
|
|
|
||
|
|
def test_engineering_demo_and_model_effects_are_separate_sections(self):
|
||
|
|
text = self.output()
|
||
|
|
self.assertIn("工程演示", text)
|
||
|
|
self.assertIn("模型效果", text)
|
||
|
|
self.assertIn("未验证(无权重与授权)", text)
|
||
|
|
self.assertIn("Jev:未接通", text)
|
||
|
|
self.assertIn("不能作为真实业务效果或审批依据", text)
|
||
|
|
|
||
|
|
def test_real_probability_stays_empty_and_demo_values_are_labeled(self):
|
||
|
|
facts = demo.run_demo()
|
||
|
|
self.assertTrue(facts["probability_is_null"], "真实概率必须为空")
|
||
|
|
self.assertEqual(facts["sandbox"]["baseline"], 0.42)
|
||
|
|
self.assertEqual(facts["sandbox"]["combined"], 0.64)
|
||
|
|
self.assertIn("人工设定", facts["sandbox"]["label"])
|
||
|
|
self.assertEqual(facts["sandbox"]["unchanged_dimensions"], ["DC-DEAL"])
|
||
|
|
|
||
|
|
def test_trajectory_keeps_failures_and_excludes_unmatched_outcomes(self):
|
||
|
|
facts = demo.run_demo()
|
||
|
|
self.assertTrue(facts["trajectory"]["failed_preserved"])
|
||
|
|
self.assertEqual(facts["trajectory"]["unmatched"], 1)
|
||
|
|
self.assertEqual(facts["trajectory"]["observed_denominator"], 0,
|
||
|
|
"未匹配材料版本的结果不得进入已观察分母")
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
unittest.main()
|