From 8544bbd302297ebb016447d637cb6d1b4bf2d0fb Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Thu, 31 Oct 2024 21:23:28 +0100 Subject: skip test_montly if current day is not present in previous months --- test.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/test.py b/test.py index 8535485..602be6d 100755 --- a/test.py +++ b/test.py @@ -1309,7 +1309,13 @@ Cancelled the monthly cmd "stuff\"""" # Last exec one month ago if now.month > 1: - one_month_ago = date(now.year, now.month - 1, now.day) + one_month_ago = None + try: + one_month_ago = date(now.year, now.month - 1, now.day) + except ValueError: + self.skipTest( + f"current day {now.day} does not exist in previous month") + else: one_month_ago = date(now.year - 1, 12, now.day) reset_state_string( @@ -1335,7 +1341,11 @@ alice: # Last exec two month ago if now.month > 2: - two_months_ago = date(now.year, now.month - 2, now.day) + try: + two_months_ago = date(now.year, now.month - 2, now.day) + except ValueError: + self.skipTest( + f"current day {now.day} does not exist two months ago") else: two_months_ago = date(now.year - 1, 12 - now.month + 1, now.day) -- cgit v1.2.3