feat(report): 完整数据版末尾增加独立年度方法参考
PyJHora 只在子进程里计算请求年及后两年。对话、校正和其余章节保持不导入时的结果。结果指纹不算这一章。 Windows 自测:隐私标记、导入扫描、结果指纹和 S7 退出码 0。阅读页、英文和年运章在此之前已通过。虚构盘 0 中英一起最高 59 秒。 Co-Authored-By: Grok (agent loop)
This commit is contained in:
co-authored by
Grok (agent loop)
parent
85e8adddbc
commit
c644881a30
@@ -73,6 +73,9 @@ def test_no_jhora_annual_skips_subprocess_and_matches_golden(monkeypatch) -> Non
|
||||
|
||||
|
||||
def test_jhora_available_still_uses_subprocess(monkeypatch) -> None:
|
||||
# 原值:_jhora_importable 为真时两个隔离函数各起一次子进程(calls == 2)
|
||||
# 新值:产品调用不传 research 时,即使可导入也不起子进程、返回 golden;传 research=True 时仍起子进程(calls == 2)
|
||||
# 原因:#93 红线 1:装包后旧回放不得进年运章
|
||||
reset_jhora_import_cache()
|
||||
monkeypatch.setattr("scripts.annual_pyjhora_replay._jhora_importable", lambda: True)
|
||||
calls = {"n": 0}
|
||||
@@ -85,12 +88,46 @@ def test_jhora_available_still_uses_subprocess(monkeypatch) -> None:
|
||||
calls["n"] += 1
|
||||
return _Completed()
|
||||
|
||||
monkeypatch.setattr("scripts.annual_pyjhora_replay.subprocess.run", _fake_run)
|
||||
def _forbid_subprocess(*_args, **_kwargs):
|
||||
raise AssertionError("product replay must not spawn a child")
|
||||
|
||||
monkeypatch.setattr("scripts.annual_pyjhora_replay.subprocess.run", _forbid_subprocess)
|
||||
tajaka = _run_isolated_tajaka_year_lord(_PROFILE, 2447893.0, _Place(), 30)
|
||||
annual = _run_isolated_annual_replay(_PROFILE, 2447893.0, _Place(), 30)
|
||||
assert calls["n"] == 0
|
||||
tajaka_golden = json.loads((FIXTURES / "tajaka-no-jhora.json").read_text(encoding="utf-8"))
|
||||
annual_golden = json.loads((FIXTURES / "annual-no-jhora.json").read_text(encoding="utf-8"))
|
||||
assert _without_hash(tajaka) == tajaka_golden
|
||||
assert _without_hash(annual) == annual_golden
|
||||
|
||||
monkeypatch.setattr("scripts.annual_pyjhora_replay.subprocess.run", _fake_run)
|
||||
_run_isolated_tajaka_year_lord(_PROFILE, 2447893.0, _Place(), 30, research=True)
|
||||
_run_isolated_annual_replay(_PROFILE, 2447893.0, _Place(), 30, research=True)
|
||||
assert calls["n"] == 2
|
||||
assert tajaka["request_hash"]
|
||||
assert annual["request_hash"]
|
||||
|
||||
|
||||
def test_product_replay_calls_a_four_arg_stand_in(monkeypatch) -> None:
|
||||
"""The 200-chart sweep replaces the runners with four-argument functions."""
|
||||
from scripts.annual_pyjhora_replay import (
|
||||
_no_jhora_annual_replay,
|
||||
_no_jhora_tajaka_replay,
|
||||
replay_pyjhora_annual,
|
||||
)
|
||||
|
||||
calls = []
|
||||
|
||||
def blocked(profile, birth_julian_day, place, age):
|
||||
calls.append(age)
|
||||
settings = {"ayanamsa": "LAHIRI", "node_mode": "mean"}
|
||||
result = _no_jhora_tajaka_replay(settings) if len(calls) == 1 else _no_jhora_annual_replay(settings)
|
||||
result["request_hash"] = "stand-in"
|
||||
return result
|
||||
|
||||
monkeypatch.setattr("scripts.annual_pyjhora_replay._run_isolated_tajaka_year_lord", blocked)
|
||||
monkeypatch.setattr("scripts.annual_pyjhora_replay._run_isolated_annual_replay", blocked)
|
||||
result = replay_pyjhora_annual(_PROFILE, birth_julian_day=2447893.0, place=_Place(), age=30)
|
||||
assert calls == [30, 30]
|
||||
assert result["status"] == "blocked"
|
||||
|
||||
|
||||
def test_pyjhora_interpreter_lookup_is_cached(monkeypatch) -> None:
|
||||
|
||||
Reference in New Issue
Block a user