mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-03-17 04:39:55 +01:00
Add Log Decorator to Bot.get_webhook_info
(#3442)
This commit is contained in:
parent
f3650364b9
commit
b8fbb89fae
2 changed files with 14 additions and 0 deletions
|
@ -3929,6 +3929,7 @@ class Bot(TelegramObject, AbstractAsyncContextManager):
|
|||
)
|
||||
return result
|
||||
|
||||
@_log
|
||||
async def get_webhook_info(
|
||||
self,
|
||||
*,
|
||||
|
|
|
@ -22,6 +22,7 @@ import datetime as dtm
|
|||
import inspect
|
||||
import logging
|
||||
import pickle
|
||||
import re
|
||||
import socket
|
||||
import sys
|
||||
import time
|
||||
|
@ -320,6 +321,18 @@ class TestBot:
|
|||
assert caplog.records[0].getMessage().startswith("Entering: get_me")
|
||||
assert caplog.records[-1].getMessage().startswith("Exiting: get_me")
|
||||
|
||||
@bot_methods(ext_bot=False)
|
||||
def test_api_methods_have_log_decorator(self, bot_class, bot_method_name, bot_method):
|
||||
"""Check that all bot methods have the log decorator ..."""
|
||||
# not islower() skips the camelcase aliases
|
||||
if not bot_method_name.islower():
|
||||
return
|
||||
source = inspect.getsource(bot_method)
|
||||
assert (
|
||||
# Use re.match to only match at *the beginning* of the string
|
||||
re.match(rf"\s*\@\_log\s*async def {bot_method_name}", source)
|
||||
), f"{bot_method_name} is missing the @_log decorator"
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"acd_in,maxsize",
|
||||
[(True, 1024), (False, 1024), (0, 0), (None, None)],
|
||||
|
|
Loading…
Add table
Reference in a new issue