Skip to content

Commit ecef8f0

Browse files
committed
test_schedule.py: fix mock now() and tests with a timezone
Signed-off-by: Steve Arnold <nerdboy@gentoo.org>
1 parent ac50643 commit ecef8f0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

test_schedule.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@ def today(cls):
3636
return cls(self.year, self.month, self.day)
3737

3838
@classmethod
39-
def now(cls):
39+
def now(cls, tz=None):
4040
return cls(self.year, self.month, self.day,
41-
self.hour, self.minute)
41+
self.hour, self.minute).replace(tzinfo=tz)
42+
4243
self.original_datetime = datetime.datetime
4344
datetime.datetime = MockDate
4445

@@ -258,7 +259,8 @@ def test_next_run_property(self):
258259
every().hour.do(hourly_job)
259260
assert len(schedule.jobs) == 2
260261
# Make sure the hourly job is first
261-
assert schedule.next_run() == original_datetime(2010, 1, 6, 14, 16)
262+
assert schedule.next_run() == original_datetime(2010, 1, 6, 14, 16,
263+
tzinfo=datetime.timezone.utc)
262264
assert schedule.idle_seconds() == 60 * 60
263265

264266
def test_cancel_job(self):

0 commit comments

Comments
 (0)