From cb9af36937adf2b15da1947d841f6a15b801bb86 Mon Sep 17 00:00:00 2001 From: Bibo-Joshi Date: Sun, 26 Jan 2020 22:07:17 +0100 Subject: [PATCH] Fix None check in JobQueue._put() (#1707) fixes #1701 --- telegram/ext/jobqueue.py | 3 ++- tests/test_jobqueue.py | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) 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)