Add deprecation warnings to Bot properties

Three properties of the Bot class - parse_mode, disable_web_page_preview, and protect_content - have been marked as deprecated with proper warning messages. The associated tests have also been added to confirm the working of these deprecation warnings. Users are advised to use the updated alternatives specified in the warning messages.
This commit is contained in:
JRoot Junior 2024-02-16 01:13:51 +02:00
parent e6e2601d4b
commit 0cf5afeb99
No known key found for this signature in database
GPG key ID: 738964250D5FF6E2
2 changed files with 54 additions and 0 deletions

View file

@ -49,6 +49,30 @@ class TestBot:
):
bot = Bot(token="42:Test", parse_mode="HTML")
def test_deprecated_parse_mode(self):
with check_deprecated(
max_version="3.5.0",
exception=AttributeError,
):
bot = Bot(token="42:Test", parse_mode="HTML")
assert bot.parse_mode == "HTML"
def test_disable_web_page_preview(self):
with check_deprecated(
max_version="3.5.0",
exception=TypeError,
):
bot = Bot(token="42:Test", disable_web_page_preview=True)
assert bot.disable_web_page_preview is True
def test_deprecated_protect_content(self):
with check_deprecated(
max_version="3.5.0",
exception=AttributeError,
):
bot = Bot(token="42:Test", protect_content=True)
assert bot.protect_content is True
def test_hashable(self):
bot = Bot("42:TEST")
assert hash(bot) == hash("42:TEST")