"""D-2 交易日判断单元测试(纯函数,无外部依赖)。""" from datetime import date from sanguo_qmt_bridge.trade_calendar import is_trading_day class TestIsTradingDay: def test_weekday_is_trading_day(self): assert is_trading_day(date(2026, 7, 13)) is True # 周一 def test_friday_is_trading_day(self): assert is_trading_day(date(2026, 7, 17)) is True # 周五 def test_saturday_is_not_trading_day(self): assert is_trading_day(date(2026, 7, 18)) is False # 周六 def test_sunday_is_not_trading_day(self): assert is_trading_day(date(2026, 7, 19)) is False # 周日 def test_default_uses_today(self): """无参数时用今天,至少返回 bool 不崩溃。""" result = is_trading_day() assert isinstance(result, bool) def test_full_week(self): """完整一周:周一到周五 True,周六周日 False。""" week = [ (date(2026, 7, 13), True), # Mon (date(2026, 7, 14), True), # Tue (date(2026, 7, 15), True), # Wed (date(2026, 7, 16), True), # Thu (date(2026, 7, 17), True), # Fri (date(2026, 7, 18), False), # Sat (date(2026, 7, 19), False), # Sun ] for day, expected in week: assert is_trading_day(day) is expected, f"{day} expected {expected}"