Skip to content

test(stats): cover span_days, time bounds, and tie-breaking#41

Merged
protosphinx merged 1 commit into
mainfrom
bot/stats-span-tiebreak-tests
May 21, 2026
Merged

test(stats): cover span_days, time bounds, and tie-breaking#41
protosphinx merged 1 commit into
mainfrom
bot/stats-span-tiebreak-tests

Conversation

@protosphinx
Copy link
Copy Markdown
Member

Why

pm_bench/stats.py has three behaviors that existing tests in test_stats.py do not exercise:

  1. span_days, earliest, and latest are only tested on an empty log (where they are trivially 0 / None). No test confirms the calculation on a real log.
  2. _top_n_sorted guarantees ties are broken lexicographically, but no test pins that contract.
  3. The single-event edge case (span = 0, all length stats = 1) is not covered.

These gaps mean a regression in summarize() could slip through CI undetected. This PR closes them with three targeted unit tests, no production-code changes.

What

  • test_summarize_span_days_and_time_bounds: verifies span_days == 2.0 and earliest/latest on the shared _events() fixture (a log that spans exactly 2 days).
  • test_summarize_single_event_span_zero: single case, single event; span = 0.0, earliest = latest = the event timestamp, all length stats = 1.
  • test_summarize_tie_breaking_is_lexicographic: in _events() both "a" and "b" appear 2 times, and "c"/"x" appear 1 time each; asserts the full ordering [("a",2), ("b",2), ("c",1), ("x",1)].

Tests

  • All 3 new tests run via pytest tests/test_stats.py
  • Full suite: 251 passing (was 248)

Self-merge gate

  • all CI checks pass
  • LOC delta < 250 (added + removed)
  • no public-API surface change
  • no runtime-dependency additions
  • no workflow file changes
  • tests added or extended

Generated by Claude Code

Three new tests for summarize() paths that were not exercised:

- span_days and earliest/latest on a concrete non-empty log (2-day span)
- single-event log: span_days == 0.0 and all length stats == 1
- _top_n_sorted tie-breaking: equal-count activities sort lexicographically
@protosphinx protosphinx added the automated Opened by the daily bot label May 21, 2026 — with Claude
@protosphinx protosphinx merged commit 0e0de9f into main May 21, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated Opened by the daily bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant