From dfa81379d4a28c75669012391a79d359b59f2646 Mon Sep 17 00:00:00 2001 From: maui314159 <4717845+maui314159@users.noreply.github.com> Date: Wed, 6 May 2026 08:16:11 -0400 Subject: [PATCH] fix: use timedelta in pr_reporting test fixture to avoid month overflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The base_prs and review_prs fixtures used recent_date.replace(day=day+N) to construct PRs offset from a "today minus 7 days" base date. When the base date landed on the last 1-2 days of a month, day+N would exceed the month length and raise ValueError: day is out of range for month. The bug fired on calendar days where today minus 7 lands on day 30/31 of a 30-day month or day 29/30/31 of a 28-day February — roughly twice per month. Surfaced today (2026-05-06: today-7 = 2026-04-29, day+2 = 31, April has only 30 days). Replace the .replace(day=...) arithmetic with timedelta(days=N), which correctly carries day overflow across month boundaries. Co-Authored-By: claude-flow --- tests/reports/test_pr_reporting.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/reports/test_pr_reporting.py b/tests/reports/test_pr_reporting.py index 9ddd84b..31e3b8c 100644 --- a/tests/reports/test_pr_reporting.py +++ b/tests/reports/test_pr_reporting.py @@ -12,7 +12,7 @@ from __future__ import annotations import csv -from datetime import datetime, timezone +from datetime import datetime, timedelta, timezone from io import StringIO from pathlib import Path from typing import Any @@ -105,8 +105,8 @@ def review_prs(recent_date: datetime) -> list[dict[str, Any]]: "title": "Add tests", "author": "bob", "canonical_id": "bob@example.com", - "created_at": recent_date.replace(day=recent_date.day + 1), - "merged_at": recent_date.replace(day=recent_date.day + 1, hour=14), + "created_at": recent_date + timedelta(days=1), + "merged_at": (recent_date + timedelta(days=1)).replace(hour=14), "additions": 150, "deletions": 0, "changed_files": 6, @@ -126,8 +126,8 @@ def review_prs(recent_date: datetime) -> list[dict[str, Any]]: "title": "Update docs", "author": "alice", "canonical_id": "alice@example.com", - "created_at": recent_date.replace(day=recent_date.day + 2), - "merged_at": recent_date.replace(day=recent_date.day + 2, hour=11), + "created_at": recent_date + timedelta(days=2), + "merged_at": (recent_date + timedelta(days=2)).replace(hour=11), "additions": 30, "deletions": 5, "changed_files": 2,