Skip to content

Commit 800997f

Browse files
sunasrd-byteclaude
andcommitted
test: pin clock in status output tests with freezegun
The credit-line and status-message tests assert on absolute dates in their fixtures, so expired/active expectations depended on the system clock. Freeze time at 2025-06-15 so the assertions hold regardless of when the suite runs. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 15961c3 commit 800997f

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ dev = [
3636
"black==26.5.1",
3737
"isort==8.0.1",
3838
"mypy==2.3.0",
39+
"freezegun==1.5.5",
3940
]
4041

4142
[project.scripts]

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ flake8==7.3.0
1818
black==26.5.1
1919
isort==8.0.1
2020
mypy==2.3.0
21+
freezegun==1.5.5

tests/test_cli_output.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from unittest.mock import Mock, patch
44

5+
from freezegun import freeze_time
6+
57
from cli_output.status import (
68
_create_progress_bar,
79
_display_bucket_credit_line,
@@ -10,6 +12,9 @@
1012
print_status,
1113
)
1214

15+
FROZEN_NOW = "2025-06-15T12:00:00+00:00"
16+
# Fixtures use absolute dates, so "now" is pinned to keep expired/active assertions valid regardless of the system clock.
17+
1318

1419
class TestProgressBar:
1520
"""Tests for _create_progress_bar function."""
@@ -52,6 +57,7 @@ def test_custom_width(self):
5257
assert bar == "█" * 5 + "░" * 5
5358

5459

60+
@freeze_time(FROZEN_NOW)
5561
class TestDisplayCreditLine:
5662
"""Tests for _display_credit_line function."""
5763

@@ -132,6 +138,7 @@ def test_timezone_naive_datetime(self, mock_console):
132138
mock_console.print.assert_called_once()
133139

134140

141+
@freeze_time(FROZEN_NOW)
135142
class TestDisplayBucketCreditLine:
136143
"""Tests for _display_bucket_credit_line function."""
137144

@@ -192,6 +199,7 @@ def test_timezone_naive_datetime(self, mock_console):
192199
mock_console.print.assert_called_once()
193200

194201

202+
@freeze_time(FROZEN_NOW)
195203
class TestDisplayStatusMessage:
196204
"""Tests for _display_status_message function."""
197205

@@ -271,6 +279,7 @@ def test_null_plan_credits_and_empty_purchased(self, mock_console):
271279
assert "No rendering credits remaining" in call_args
272280

273281

282+
@freeze_time(FROZEN_NOW)
274283
class TestPrintStatus:
275284
"""Tests for print_status function."""
276285

0 commit comments

Comments
 (0)