diff --git a/telegram/ext/jobqueue.py b/telegram/ext/jobqueue.py index 5a04d4ea5..28c9a1a87 100644 --- a/telegram/ext/jobqueue.py +++ b/telegram/ext/jobqueue.py @@ -95,7 +95,8 @@ class JobQueue(object): """ # 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: raise ValueError("no time specification given for scheduling non-repeating job") next_t = to_float_timestamp(time_spec, reference_timestamp=previous_t) diff --git a/tests/test_jobqueue.py b/tests/test_jobqueue.py index 4b5d8d108..664254f4b 100644 --- a/tests/test_jobqueue.py +++ b/tests/test_jobqueue.py @@ -119,6 +119,11 @@ class TestJobQueue(object): sleep(0.07) 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): """Test correct scheduling of job when passing a timezone-aware datetime as ``first``""" first = (dtm.datetime.utcnow() + timezone.utcoffset(None)).replace(tzinfo=timezone)