mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-03-29 01:37:28 +01:00
parent
fbb7e0e645
commit
cb9af36937
2 changed files with 7 additions and 1 deletions
|
@ -95,7 +95,8 @@ class JobQueue(object):
|
||||||
|
|
||||||
"""
|
"""
|
||||||
# get time at which to run:
|
# get time at which to run:
|
||||||
time_spec = time_spec or job.interval
|
if time_spec is None:
|
||||||
|
time_spec = job.interval
|
||||||
if time_spec is None:
|
if time_spec is None:
|
||||||
raise ValueError("no time specification given for scheduling non-repeating job")
|
raise ValueError("no time specification given for scheduling non-repeating job")
|
||||||
next_t = to_float_timestamp(time_spec, reference_timestamp=previous_t)
|
next_t = to_float_timestamp(time_spec, reference_timestamp=previous_t)
|
||||||
|
|
|
@ -119,6 +119,11 @@ class TestJobQueue(object):
|
||||||
sleep(0.07)
|
sleep(0.07)
|
||||||
assert self.result == 1
|
assert self.result == 1
|
||||||
|
|
||||||
|
def test_run_repeating_first_immediate(self, job_queue):
|
||||||
|
job_queue.run_repeating(self.job_run_once, 0.1, first=0)
|
||||||
|
sleep(0.05)
|
||||||
|
assert self.result == 1
|
||||||
|
|
||||||
def test_run_repeating_first_timezone(self, job_queue, timezone):
|
def test_run_repeating_first_timezone(self, job_queue, timezone):
|
||||||
"""Test correct scheduling of job when passing a timezone-aware datetime as ``first``"""
|
"""Test correct scheduling of job when passing a timezone-aware datetime as ``first``"""
|
||||||
first = (dtm.datetime.utcnow() + timezone.utcoffset(None)).replace(tzinfo=timezone)
|
first = (dtm.datetime.utcnow() + timezone.utcoffset(None)).replace(tzinfo=timezone)
|
||||||
|
|
Loading…
Add table
Reference in a new issue