Add Log Decorator to Bot.get_webhook_info (#3442)

This commit is contained in:
Bibo-Joshi 2022-12-27 19:02:50 +01:00 committed by GitHub
parent f3650364b9
commit b8fbb89fae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View file

@ -3929,6 +3929,7 @@ class Bot(TelegramObject, AbstractAsyncContextManager):
)
return result
@_log
async def get_webhook_info(
self,
*,

View file

@ -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)],