Skip to content

Commit 171020d

Browse files
anthonyciccAnthony Cicchetti
andauthored
🐛 fix Cron Tests (Happy New Year 🎉 ) (#361)
Co-authored-by: Anthony Cicchetti <anthony@anthonycicchetti.com>
1 parent 1873338 commit 171020d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tests/test_cron.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,12 @@ def test_cron_str_next_after() -> None:
4040
cron_value = CronStr('15 8 * * 1-5')
4141
next_run = cron_value.next_after(datetime(2024, 1, 1, 7, 0))
4242
assert next_run == datetime(2024, 1, 1, 8, 15)
43-
current_year = datetime.now(timezone.utc).year
44-
assert cron_value.next_run.startswith(str(current_year)) # sanity check for property access
43+
now = datetime.now(timezone.utc)
44+
current_year = now.year
45+
if now.month == 12 and now.day == 31: # "If it's Dec 31, the next invocation is actually in the new year
46+
assert cron_value.next_run.startswith(str(current_year + 1))
47+
else:
48+
assert cron_value.next_run.startswith(str(current_year)) # sanity check for property access
4549

4650

4751
def test_cron_str_strips_whitespace() -> None:

0 commit comments

Comments
 (0)