mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-21 14:46:29 +01:00
Remove Deprecation Warning in JobQueue.run_daily
(#4206)
This commit is contained in:
parent
58b8ef4ce4
commit
42b68f1a70
2 changed files with 1 additions and 31 deletions
|
@ -33,7 +33,6 @@ except ImportError:
|
|||
|
||||
from telegram._utils.repr import build_repr_with_selected_attrs
|
||||
from telegram._utils.types import JSONDict
|
||||
from telegram._utils.warnings import warn
|
||||
from telegram.ext._extbot import ExtBot
|
||||
from telegram.ext._utils.types import CCT, JobCallback
|
||||
|
||||
|
@ -587,13 +586,6 @@ class JobQueue(Generic[CCT]):
|
|||
queue.
|
||||
|
||||
"""
|
||||
# TODO: After v20.0, we should remove this warning.
|
||||
if days != tuple(range(7)): # checks if user passed a custom value
|
||||
warn(
|
||||
"Prior to v20.0 the `days` parameter was not aligned to that of cron's weekday "
|
||||
"scheme. We recommend double checking if the passed value is correct.",
|
||||
stacklevel=2,
|
||||
)
|
||||
if not job_kwargs:
|
||||
job_kwargs = {}
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@ import time
|
|||
import pytest
|
||||
|
||||
from telegram.ext import ApplicationBuilder, CallbackContext, ContextTypes, Defaults, Job, JobQueue
|
||||
from telegram.warnings import PTBUserWarning
|
||||
from tests.auxil.envvars import GITHUB_ACTION, TEST_WITH_OPT_DEPS
|
||||
from tests.auxil.pytest_classes import make_bot
|
||||
from tests.auxil.slots import mro_slots
|
||||
|
@ -80,11 +79,6 @@ class TestJobQueue:
|
|||
job_time = 0
|
||||
received_error = None
|
||||
|
||||
expected_warning = (
|
||||
"Prior to v20.0 the `days` parameter was not aligned to that of cron's weekday scheme."
|
||||
" We recommend double checking if the passed value is correct."
|
||||
)
|
||||
|
||||
async def test_repr(self, app):
|
||||
jq = JobQueue()
|
||||
jq.set_application(app)
|
||||
|
@ -375,20 +369,8 @@ class TestJobQueue:
|
|||
scheduled_time = job_queue.jobs()[0].next_t.timestamp()
|
||||
assert scheduled_time == pytest.approx(expected_reschedule_time)
|
||||
|
||||
async def test_run_daily_warning(self, job_queue, recwarn):
|
||||
delta, now = 1, dtm.datetime.now(UTC)
|
||||
time_of_day = (now + dtm.timedelta(seconds=delta)).time()
|
||||
|
||||
job_queue.run_daily(self.job_run_once, time_of_day)
|
||||
assert len(recwarn) == 0
|
||||
job_queue.run_daily(self.job_run_once, time_of_day, days=(0, 1, 2, 3))
|
||||
assert len(recwarn) == 1
|
||||
assert str(recwarn[0].message) == self.expected_warning
|
||||
assert recwarn[0].category is PTBUserWarning
|
||||
assert recwarn[0].filename == __file__, "wrong stacklevel"
|
||||
|
||||
@pytest.mark.parametrize("weekday", [0, 1, 2, 3, 4, 5, 6])
|
||||
async def test_run_daily_days_of_week(self, job_queue, recwarn, weekday):
|
||||
async def test_run_daily_days_of_week(self, job_queue, weekday):
|
||||
delta, now = 1, dtm.datetime.now(UTC)
|
||||
time_of_day = (now + dtm.timedelta(seconds=delta)).time()
|
||||
# offset in days until next weekday
|
||||
|
@ -400,10 +382,6 @@ class TestJobQueue:
|
|||
await asyncio.sleep(delta + 0.1)
|
||||
scheduled_time = job_queue.jobs()[0].next_t.timestamp()
|
||||
assert scheduled_time == pytest.approx(expected_reschedule_time)
|
||||
assert len(recwarn) == 1
|
||||
assert str(recwarn[0].message) == self.expected_warning
|
||||
assert recwarn[0].category is PTBUserWarning
|
||||
assert recwarn[0].filename == __file__, "wrong stacklevel"
|
||||
|
||||
async def test_run_monthly(self, job_queue, timezone):
|
||||
delta, now = 1, dtm.datetime.now(timezone)
|
||||
|
|
Loading…
Reference in a new issue