fix(tests): week-дата тест устойчив к версии Python (fromisoformat строгий на <3.11)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
anor
2026-07-18 18:09:52 +10:00
co-authored by Claude Opus 4.8
parent c9b3507556
commit f8b379b973
+8 -5
View File
@@ -67,10 +67,13 @@ def test_date_block_actually_injected_into_prompt():
assert "2019-06-01" not in g._build_system_prompt() # без даты — блока нет (обратная совм.)
def test_week_date_rejected_by_roundtrip():
"""Fable: «2019-W01-1» (10 символов, парсится в 2018-12-31) — не каноническая дата, endpoint
отвергает по round-trip (сохраняем d.isoformat(), сверяем с вводом)."""
def test_week_date_rejected():
"""Fable: «2019-W01-1» (10 символов) endpoint отвергает — на Python<3.11 fromisoformat бросает
сразу, на 3.11+ парсится в 2018-12-31, но round-trip не совпадает. Оба пути → 400."""
import datetime
d = datetime.date.fromisoformat("2019-W01-1")
assert d.isoformat() != "2019-W01-1" # не совпало → endpoint вернёт 400
bad = "2019-W01-1"
try:
assert datetime.date.fromisoformat(bad).isoformat() != bad # 3.11+: не каноническая
except ValueError:
pass # <3.11: отвергнута сразу
assert datetime.date.fromisoformat("2019-06-01").isoformat() == "2019-06-01" # обычная — ок