Repository navigation
Conversation
Novvex-AI
commented
Nov 10, 2026
- Diff: 1 file, +30/-0
humanize() can emit the impossible string "12 months". The month count is clamped to 12 via `calendar_months = min(calendar_months, 12)` while the month branch is guarded by `diff < _SECS_PER_YEAR`. Those two rules overlap for 350-364 days: relativedelta reports "11 months + 15..29 days", the `days > 14` rounding pushes the count to 12, the clamp keeps it at 12, and the guard still passes because the elapsed seconds are below a full year. At 365 days the year guard fails and the output correctly becomes "a year". No test asserted this boundary, so the behaviour is unpinned. Add a regression test covering the future, past and only_distance forms.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1408 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 10 10
Lines 2315 2315
Branches 358 358
=========================================
Hits 2315 2315 ☔ View full report in Codecov by Harness. |
|
Could the intended contract be made explicit? If this is a characterization test, rename it and explain why twelve-month output should remain valid. If the intent is to prevent that output, assert the intended year result and include the behavior change so the test fails before the fix and passes afterward. Keep the 365-day control either way. Source review of head 76671cc and its assertions; I have not run the Arrow suite. Prepared with AI assistance. |
Rename test_months_never_reach_twelve to test_humanize_emits_twelve_months_before_a_year and rewrite its comment as a docstring that states the contract plainly: this test pins current behaviour, it does not assert that "12 months" is desirable. The old name and comment claimed the month branch must never emit "12 months" while the assertions required exactly that, so the test contradicted itself (raised by brunnojob on arrow-py#1408). The assertions are unchanged and still cover future, past and only_distance at 350/364 days, plus the 365-day control that must report "a year". No production code changes: humanize() still emits "12 months" for 350-364 days. If that is ever changed, this test is expected to fail and should be updated alongside the fix. Verified locally: 226 passed in tests/test_arrow.py.
|
Thanks, you are right that the name and comment contradicted the assertions. This PR is a characterization test, not a behaviour fix. The intent was to pin what
Verified locally: |