From 765ff66ce50341733b291a290e96d45b8aa8ed48 Mon Sep 17 00:00:00 2001 From: 732642856 <732642856@qq.com> Date: Fri, 2 Oct 2026 14:52:14 +0800 Subject: [PATCH] test: cover Badhaka ascendant rules (cherry picked from commit 6abfe98396af376c0d010f833ea9c0d8ce8595ad) --- tests/test_badhaka_rules.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/test_badhaka_rules.py diff --git a/tests/test_badhaka_rules.py b/tests/test_badhaka_rules.py new file mode 100644 index 00000000..86a9369b --- /dev/null +++ b/tests/test_badhaka_rules.py @@ -0,0 +1,25 @@ +import sys +from pathlib import Path + + +ROOT = Path(__file__).resolve().parents[1] +sys.path.insert(0, str(ROOT / 'scripts')) + +from yoga_engine import YogaContext # noqa: E402 + + +def test_badhaka_houses_follow_chara_sthira_dual_rule_for_all_lagnas() -> None: + expected = { + 'Aries': 11, 'Cancer': 11, 'Libra': 11, 'Capricorn': 11, + 'Taurus': 9, 'Leo': 9, 'Scorpio': 9, 'Aquarius': 9, + 'Gemini': 7, 'Virgo': 7, 'Sagittarius': 7, 'Pisces': 7, + } + for ascendant, house in expected.items(): + context = YogaContext({}, ascendant) + assert context.is_badhaka(house) is True + assert context.is_badhaka(1 if house != 1 else 2) is False + + +def test_badhaka_rule_is_structural_and_does_not_emit_lifespan_claims() -> None: + source = (ROOT / 'scripts' / 'yoga_engine.py').read_text(encoding='utf-8') + assert '过早死亡风险' not in source