Add representation for aiogram exception (#989)

* feat: add repr for aiogram exception

#988

* docs: add changelog

#988

* tests: add representation coverage

#988

* fix: correct test result type

#988
This commit is contained in:
Oleg A 2022-09-11 23:16:47 +03:00 committed by GitHub
parent 0b5f4d62c7
commit a08c2e750c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 0 deletions

1
CHANGES/988.feature Normal file
View file

@ -0,0 +1 @@
Added message text to aiogram exceptions representation

View file

@ -23,6 +23,9 @@ class DetailedAiogramError(AiogramError):
message += f"\n(background on this error at: {self.url})" message += f"\n(background on this error at: {self.url})"
return message return message
def __repr__(self) -> str:
return f"{type(self).__name__}('{self}')"
class TelegramAPIError(DetailedAiogramError): class TelegramAPIError(DetailedAiogramError):
def __init__( def __init__(

View file

@ -0,0 +1,15 @@
import pytest
from aiogram.exceptions import DetailedAiogramError
class TestException:
@pytest.mark.parametrize(
"message,result",
[
["reason", "DetailedAiogramError('reason')"],
],
)
def test_representation(self, message: str, result: str):
exc = DetailedAiogramError(message=message)
assert repr(exc) == result