self=<tests._files.test_sticker.TestStickerSetWithRequestobjectat0x7f807160ae40>bot=PytestExtBot[token=1055397471:AAG18nB_S2WAwuJ3g7ohKBVgXXceMnIOySc]chat_id='675666224'asyncdeftest_bot_methods_1_tgs(self,bot,chat_id):awaitasyncio.sleep(1)>assertawaitbot.add_sticker_to_set(chat_id,f"animated_test_by_{bot.username}",sticker=InputSticker(sticker=data_file("telegram_animated_sticker.tgs").open("rb"),emoji_list=["#x1F604"],format=StickerFormat.ANIMATED, ), )tests/_files/test_sticker.py:830: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _telegram/ext/_extbot.py:910:inadd_sticker_to_setreturnawaitsuper().add_sticker_to_set(telegram/_bot.py:6570:inadd_sticker_to_setreturnawaitself._post(telegram/_bot.py:618:in_postreturnawaitself._do_post(telegram/ext/_extbot.py:352:in_do_postreturnawaitsuper()._do_post(telegram/_bot.py:647:in_do_postresult=awaitrequest.post(telegram/request/_baserequest.py:202:inpostresult=awaitself._request_wrapper(tests/auxil/networking.py:48:in_request_wrapperreturnawaitsuper()._request_wrapper(__ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _self=<tests.auxil.networking.NonchalantHttpxRequestobjectat0x7f807146ee40>url='https://api.telegram.org/bot1055397471:AAG18nB_S2WAwuJ3g7ohKBVgXXceMnIOySc/addStickerToSet'method='POST'request_data=<telegram.request._requestdata.RequestDataobjectat0x7f806da8ca60>read_timeout=None,write_timeout=None,connect_timeout=Nonepool_timeout=Noneasyncdef_request_wrapper(self,url:str,method:str,request_data:Optional[RequestData]=None,read_timeout:ODVInput[float]=DEFAULT_NONE,write_timeout:ODVInput[float]=DEFAULT_NONE,connect_timeout:ODVInput[float]=DEFAULT_NONE,pool_timeout:ODVInput[float]=DEFAULT_NONE, )->bytes:"""Wraps the real implementation request method. Performs the following tasks: * Handle the various HTTP response codes. * Parse the Telegram server response. Args: url (:obj:`str`): The URL to request. method (:obj:`str`): HTTP method (i.e. 'POST', 'GET', etc.). request_data (:class:`telegram.request.RequestData`, optional): An object containing information about parameters and files to upload for the request. read_timeout (:obj:`float` | :obj:`None`, optional): If passed, specifies the maximum amount of time (in seconds) to wait for a response from Telegram's server instead of the time specified during creating of this object. Defaults to :attr:`DEFAULT_NONE`. write_timeout (:obj:`float` | :obj:`None`, optional): If passed, specifies the maximum amount of time (in seconds) to wait for a write operation to complete (in terms of a network socket; i.e. POSTing a request or uploading a file) instead of the time specified during creating of this object. Defaults to :attr:`DEFAULT_NONE`. connect_timeout (:obj:`float` | :obj:`None`, optional): If passed, specifies the maximum amount of time (in seconds) to wait for a connection attempt to a server to succeed instead of the time specified during creating of this object. Defaults to :attr:`DEFAULT_NONE`. pool_timeout (:obj:`float` | :obj:`None`, optional): If passed, specifies the maximum amount of time (in seconds) to wait for a connection to become available instead of the time specified during creating of this object. Defaults to :attr:`DEFAULT_NONE`. Returns: bytes: The payload part of the HTTP server response. Raises: TelegramError """# Import needs to be here since HTTPXRequest is a subclass of BaseRequestfromtelegram.requestimportHTTPXRequest# pylint: disable=import-outside-toplevel# 20 is the documented default value for all the media related bot methods and custom# implementations of BaseRequest may explicitly rely on that. Hence, we follow the# standard deprecation policy and deprecate starting with version 20.7.# For our own implementation HTTPXRequest, we can handle that ourselves, so we skip the# warning in that case.has_files=request_dataandrequest_data.multipart_dataif (has_filesandnotisinstance(self,HTTPXRequest)andisinstance(write_timeout,DefaultValue) ):warn(PTBDeprecationWarning("20.7",f"The `write_timeout` parameter passed to{self.__class__.__name__}.do_request"" will default to `BaseRequest.DEFAULT_NONE` instead of 20 in future versions ""for *all* methods of the `Bot` class, including methods sending media.", ),stacklevel=3, )write_timeout=20try:code,payload=awaitself.do_request(url=url,method=method,request_data=request_data,read_timeout=read_timeout,write_timeout=write_timeout,connect_timeout=connect_timeout,pool_timeout=pool_timeout, )exceptTelegramError:raiseexceptExceptionasexc:raiseNetworkError(f"Unknown error in HTTP implementation:{exc!r}")fromexcifHTTPStatus.OK<=code<=299:# 200-299 range are HTTP success statusesreturnpayloadresponse_data=self.parse_json_payload(payload)description=response_data.get("description")message=descriptionifdescriptionelse"Unknown HTTPError"# In some special cases, we can raise more informative exceptions:# see https://core.telegram.org/bots/api#responseparameters and# https://core.telegram.org/bots/api#making-requests# TGs response also has the fields 'ok' and 'error_code'.# However, we rather rely on the HTTP status code for now.parameters=response_data.get("parameters")ifparameters:migrate_to_chat_id=parameters.get("migrate_to_chat_id")ifmigrate_to_chat_id:raiseChatMigrated(migrate_to_chat_id)retry_after=parameters.get("retry_after")ifretry_after:raiseRetryAfter(retry_after)message+=f"\nThe server response contained unknown parameters:{parameters}"ifcode==HTTPStatus.FORBIDDEN:# 403raiseForbidden(message)ifcodein (HTTPStatus.NOT_FOUND,HTTPStatus.UNAUTHORIZED):# 404 and 401# TG returns 404 Not found for# 1) malformed tokens# 2) correct tokens but non-existing method, e.g. api.tg.org/botTOKEN/unkonwnMethod# 2) is relevant only for Bot.do_api_request, where we have special handing for it.# TG returns 401 Unauthorized for correctly formatted tokens that are not validraiseInvalidToken(message)ifcode==HTTPStatus.BAD_REQUEST:# 400>raiseBadRequest(message)Etelegram.error.BadRequest:Wrongfiletypetelegram/request/_baserequest.py:383:BadRequest
No description provided.