Remove assert statement from non-test files

This commit is contained in:
deepsource-autofix[bot] 2020-11-08 21:48:49 +00:00 committed by GitHub
parent 44cd1fd974
commit dd50a9b13e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 637 additions and 323 deletions

View file

@ -7,34 +7,49 @@ animation = types.Animation(**ANIMATION)
def test_export():
exported = animation.to_python()
assert isinstance(exported, dict)
assert exported == ANIMATION
if not isinstance(exported, dict):
raise AssertionError
if exported != ANIMATION:
raise AssertionError
def test_file_name():
assert isinstance(animation.file_name, str)
assert animation.file_name == ANIMATION['file_name']
if not isinstance(animation.file_name, str):
raise AssertionError
if animation.file_name != ANIMATION['file_name']:
raise AssertionError
def test_mime_type():
assert isinstance(animation.mime_type, str)
assert animation.mime_type == ANIMATION['mime_type']
if not isinstance(animation.mime_type, str):
raise AssertionError
if animation.mime_type != ANIMATION['mime_type']:
raise AssertionError
def test_file_id():
assert isinstance(animation.file_id, str)
if not isinstance(animation.file_id, str):
raise AssertionError
# assert hash(animation) == ANIMATION['file_id']
assert animation.file_id == ANIMATION['file_id']
if animation.file_id != ANIMATION['file_id']:
raise AssertionError
def test_file_size():
assert isinstance(animation.file_size, int)
assert animation.file_size == ANIMATION['file_size']
if not isinstance(animation.file_size, int):
raise AssertionError
if animation.file_size != ANIMATION['file_size']:
raise AssertionError
def test_thumb():
assert isinstance(animation.thumb, types.PhotoSize)
assert animation.thumb.file_id == ANIMATION['thumb']['file_id']
assert animation.thumb.width == ANIMATION['thumb']['width']
assert animation.thumb.height == ANIMATION['thumb']['height']
assert animation.thumb.file_size == ANIMATION['thumb']['file_size']
if not isinstance(animation.thumb, types.PhotoSize):
raise AssertionError
if animation.thumb.file_id != ANIMATION['thumb']['file_id']:
raise AssertionError
if animation.thumb.width != ANIMATION['thumb']['width']:
raise AssertionError
if animation.thumb.height != ANIMATION['thumb']['height']:
raise AssertionError
if animation.thumb.file_size != ANIMATION['thumb']['file_size']:
raise AssertionError

View file

@ -7,56 +7,87 @@ chat = types.Chat(**CHAT)
def test_export():
exported = chat.to_python()
assert isinstance(exported, dict)
assert exported == CHAT
if not isinstance(exported, dict):
raise AssertionError
if exported != CHAT:
raise AssertionError
def test_id():
assert isinstance(chat.id, int)
assert chat.id == CHAT['id']
if not isinstance(chat.id, int):
raise AssertionError
if chat.id != CHAT['id']:
raise AssertionError
# assert hash(chat) == CHAT['id']
def test_name():
assert isinstance(chat.first_name, str)
assert chat.first_name == CHAT['first_name']
if not isinstance(chat.first_name, str):
raise AssertionError
if chat.first_name != CHAT['first_name']:
raise AssertionError
assert isinstance(chat.last_name, str)
assert chat.last_name == CHAT['last_name']
if not isinstance(chat.last_name, str):
raise AssertionError
if chat.last_name != CHAT['last_name']:
raise AssertionError
assert isinstance(chat.username, str)
assert chat.username == CHAT['username']
if not isinstance(chat.username, str):
raise AssertionError
if chat.username != CHAT['username']:
raise AssertionError
def test_type():
assert isinstance(chat.type, str)
assert chat.type == CHAT['type']
if not isinstance(chat.type, str):
raise AssertionError
if chat.type != CHAT['type']:
raise AssertionError
def test_chat_types():
assert types.ChatType.PRIVATE == 'private'
assert types.ChatType.GROUP == 'group'
assert types.ChatType.SUPER_GROUP == 'supergroup'
assert types.ChatType.CHANNEL == 'channel'
if types.ChatType.PRIVATE != 'private':
raise AssertionError
if types.ChatType.GROUP != 'group':
raise AssertionError
if types.ChatType.SUPER_GROUP != 'supergroup':
raise AssertionError
if types.ChatType.CHANNEL != 'channel':
raise AssertionError
def test_chat_type_filters():
from . import test_message
assert types.ChatType.is_private(test_message.message)
assert not types.ChatType.is_group(test_message.message)
assert not types.ChatType.is_super_group(test_message.message)
assert not types.ChatType.is_group_or_super_group(test_message.message)
assert not types.ChatType.is_channel(test_message.message)
if not types.ChatType.is_private(test_message.message):
raise AssertionError
if types.ChatType.is_group(test_message.message):
raise AssertionError
if types.ChatType.is_super_group(test_message.message):
raise AssertionError
if types.ChatType.is_group_or_super_group(test_message.message):
raise AssertionError
if types.ChatType.is_channel(test_message.message):
raise AssertionError
def test_chat_actions():
assert types.ChatActions.TYPING == 'typing'
assert types.ChatActions.UPLOAD_PHOTO == 'upload_photo'
assert types.ChatActions.RECORD_VIDEO == 'record_video'
assert types.ChatActions.UPLOAD_VIDEO == 'upload_video'
assert types.ChatActions.RECORD_AUDIO == 'record_audio'
assert types.ChatActions.UPLOAD_AUDIO == 'upload_audio'
assert types.ChatActions.UPLOAD_DOCUMENT == 'upload_document'
assert types.ChatActions.FIND_LOCATION == 'find_location'
assert types.ChatActions.RECORD_VIDEO_NOTE == 'record_video_note'
assert types.ChatActions.UPLOAD_VIDEO_NOTE == 'upload_video_note'
if types.ChatActions.TYPING != 'typing':
raise AssertionError
if types.ChatActions.UPLOAD_PHOTO != 'upload_photo':
raise AssertionError
if types.ChatActions.RECORD_VIDEO != 'record_video':
raise AssertionError
if types.ChatActions.UPLOAD_VIDEO != 'upload_video':
raise AssertionError
if types.ChatActions.RECORD_AUDIO != 'record_audio':
raise AssertionError
if types.ChatActions.UPLOAD_AUDIO != 'upload_audio':
raise AssertionError
if types.ChatActions.UPLOAD_DOCUMENT != 'upload_document':
raise AssertionError
if types.ChatActions.FIND_LOCATION != 'find_location':
raise AssertionError
if types.ChatActions.RECORD_VIDEO_NOTE != 'record_video_note':
raise AssertionError
if types.ChatActions.UPLOAD_VIDEO_NOTE != 'upload_video_note':
raise AssertionError

View file

@ -7,72 +7,111 @@ chat_member = types.ChatMember(**CHAT_MEMBER)
def test_export():
exported = chat_member.to_python()
assert isinstance(exported, dict)
assert exported == CHAT_MEMBER
if not isinstance(exported, dict):
raise AssertionError
if exported != CHAT_MEMBER:
raise AssertionError
def test_user():
assert isinstance(chat_member.user, types.User)
if not isinstance(chat_member.user, types.User):
raise AssertionError
def test_status():
assert isinstance(chat_member.status, str)
assert chat_member.status == CHAT_MEMBER['status']
if not isinstance(chat_member.status, str):
raise AssertionError
if chat_member.status != CHAT_MEMBER['status']:
raise AssertionError
def test_privileges():
assert isinstance(chat_member.can_be_edited, bool)
assert chat_member.can_be_edited == CHAT_MEMBER['can_be_edited']
if not isinstance(chat_member.can_be_edited, bool):
raise AssertionError
if chat_member.can_be_edited != CHAT_MEMBER['can_be_edited']:
raise AssertionError
assert isinstance(chat_member.can_change_info, bool)
assert chat_member.can_change_info == CHAT_MEMBER['can_change_info']
if not isinstance(chat_member.can_change_info, bool):
raise AssertionError
if chat_member.can_change_info != CHAT_MEMBER['can_change_info']:
raise AssertionError
assert isinstance(chat_member.can_delete_messages, bool)
assert chat_member.can_delete_messages == CHAT_MEMBER['can_delete_messages']
if not isinstance(chat_member.can_delete_messages, bool):
raise AssertionError
if chat_member.can_delete_messages != CHAT_MEMBER['can_delete_messages']:
raise AssertionError
assert isinstance(chat_member.can_invite_users, bool)
assert chat_member.can_invite_users == CHAT_MEMBER['can_invite_users']
if not isinstance(chat_member.can_invite_users, bool):
raise AssertionError
if chat_member.can_invite_users != CHAT_MEMBER['can_invite_users']:
raise AssertionError
assert isinstance(chat_member.can_restrict_members, bool)
assert chat_member.can_restrict_members == CHAT_MEMBER['can_restrict_members']
if not isinstance(chat_member.can_restrict_members, bool):
raise AssertionError
if chat_member.can_restrict_members != CHAT_MEMBER['can_restrict_members']:
raise AssertionError
assert isinstance(chat_member.can_pin_messages, bool)
assert chat_member.can_pin_messages == CHAT_MEMBER['can_pin_messages']
if not isinstance(chat_member.can_pin_messages, bool):
raise AssertionError
if chat_member.can_pin_messages != CHAT_MEMBER['can_pin_messages']:
raise AssertionError
assert isinstance(chat_member.can_promote_members, bool)
assert chat_member.can_promote_members == CHAT_MEMBER['can_promote_members']
if not isinstance(chat_member.can_promote_members, bool):
raise AssertionError
if chat_member.can_promote_members != CHAT_MEMBER['can_promote_members']:
raise AssertionError
def test_int():
assert int(chat_member) == chat_member.user.id
assert isinstance(int(chat_member), int)
if int(chat_member) != chat_member.user.id:
raise AssertionError
if not isinstance(int(chat_member), int):
raise AssertionError
def test_chat_member_status():
assert types.ChatMemberStatus.CREATOR == 'creator'
assert types.ChatMemberStatus.ADMINISTRATOR == 'administrator'
assert types.ChatMemberStatus.MEMBER == 'member'
assert types.ChatMemberStatus.RESTRICTED == 'restricted'
assert types.ChatMemberStatus.LEFT == 'left'
assert types.ChatMemberStatus.KICKED == 'kicked'
if types.ChatMemberStatus.CREATOR != 'creator':
raise AssertionError
if types.ChatMemberStatus.ADMINISTRATOR != 'administrator':
raise AssertionError
if types.ChatMemberStatus.MEMBER != 'member':
raise AssertionError
if types.ChatMemberStatus.RESTRICTED != 'restricted':
raise AssertionError
if types.ChatMemberStatus.LEFT != 'left':
raise AssertionError
if types.ChatMemberStatus.KICKED != 'kicked':
raise AssertionError
def test_chat_member_status_filters():
assert types.ChatMemberStatus.is_chat_admin(chat_member.status)
assert types.ChatMemberStatus.is_chat_member(chat_member.status)
if not types.ChatMemberStatus.is_chat_admin(chat_member.status):
raise AssertionError
if not types.ChatMemberStatus.is_chat_member(chat_member.status):
raise AssertionError
assert types.ChatMemberStatus.is_chat_admin(types.ChatMemberStatus.CREATOR)
assert types.ChatMemberStatus.is_chat_admin(types.ChatMemberStatus.ADMINISTRATOR)
if not types.ChatMemberStatus.is_chat_admin(types.ChatMemberStatus.CREATOR):
raise AssertionError
if not types.ChatMemberStatus.is_chat_admin(types.ChatMemberStatus.ADMINISTRATOR):
raise AssertionError
assert types.ChatMemberStatus.is_chat_member(types.ChatMemberStatus.CREATOR)
assert types.ChatMemberStatus.is_chat_member(types.ChatMemberStatus.ADMINISTRATOR)
assert types.ChatMemberStatus.is_chat_member(types.ChatMemberStatus.MEMBER)
assert types.ChatMemberStatus.is_chat_member(types.ChatMemberStatus.RESTRICTED)
if not types.ChatMemberStatus.is_chat_member(types.ChatMemberStatus.CREATOR):
raise AssertionError
if not types.ChatMemberStatus.is_chat_member(types.ChatMemberStatus.ADMINISTRATOR):
raise AssertionError
if not types.ChatMemberStatus.is_chat_member(types.ChatMemberStatus.MEMBER):
raise AssertionError
if not types.ChatMemberStatus.is_chat_member(types.ChatMemberStatus.RESTRICTED):
raise AssertionError
assert not types.ChatMemberStatus.is_chat_member(types.ChatMemberStatus.LEFT)
assert not types.ChatMemberStatus.is_chat_member(types.ChatMemberStatus.KICKED)
if types.ChatMemberStatus.is_chat_member(types.ChatMemberStatus.LEFT):
raise AssertionError
if types.ChatMemberStatus.is_chat_member(types.ChatMemberStatus.KICKED):
raise AssertionError
def test_chat_member_filters():
assert chat_member.is_chat_admin()
assert chat_member.is_chat_member()
if not chat_member.is_chat_admin():
raise AssertionError
if not chat_member.is_chat_member():
raise AssertionError

View file

@ -7,30 +7,41 @@ document = types.Document(**DOCUMENT)
def test_export():
exported = document.to_python()
assert isinstance(exported, dict)
assert exported == DOCUMENT
if not isinstance(exported, dict):
raise AssertionError
if exported != DOCUMENT:
raise AssertionError
def test_file_name():
assert isinstance(document.file_name, str)
assert document.file_name == DOCUMENT['file_name']
if not isinstance(document.file_name, str):
raise AssertionError
if document.file_name != DOCUMENT['file_name']:
raise AssertionError
def test_mime_type():
assert isinstance(document.mime_type, str)
assert document.mime_type == DOCUMENT['mime_type']
if not isinstance(document.mime_type, str):
raise AssertionError
if document.mime_type != DOCUMENT['mime_type']:
raise AssertionError
def test_file_id():
assert isinstance(document.file_id, str)
if not isinstance(document.file_id, str):
raise AssertionError
# assert hash(document) == DOCUMENT['file_id']
assert document.file_id == DOCUMENT['file_id']
if document.file_id != DOCUMENT['file_id']:
raise AssertionError
def test_file_size():
assert isinstance(document.file_size, int)
assert document.file_size == DOCUMENT['file_size']
if not isinstance(document.file_size, int):
raise AssertionError
if document.file_size != DOCUMENT['file_size']:
raise AssertionError
def test_thumb():
assert document.thumb is None
if document.thumb is not None:
raise AssertionError

View file

@ -7,25 +7,35 @@ game = types.Game(**GAME)
def test_export():
exported = game.to_python()
assert isinstance(exported, dict)
assert exported == GAME
if not isinstance(exported, dict):
raise AssertionError
if exported != GAME:
raise AssertionError
def test_title():
assert isinstance(game.title, str)
assert game.title == GAME['title']
if not isinstance(game.title, str):
raise AssertionError
if game.title != GAME['title']:
raise AssertionError
def test_description():
assert isinstance(game.description, str)
assert game.description == GAME['description']
if not isinstance(game.description, str):
raise AssertionError
if game.description != GAME['description']:
raise AssertionError
def test_photo():
assert isinstance(game.photo, list)
assert len(game.photo) == len(GAME['photo'])
assert all(map(lambda t: isinstance(t, types.PhotoSize), game.photo))
if not isinstance(game.photo, list):
raise AssertionError
if len(game.photo) != len(GAME['photo']):
raise AssertionError
if not all(map(lambda t: isinstance(t, types.PhotoSize), game.photo)):
raise AssertionError
def test_animation():
assert isinstance(game.animation, types.Animation)
if not isinstance(game.animation, types.Animation):
raise AssertionError

View file

@ -21,21 +21,31 @@ def test_field_width():
"""
https://core.telegram.org/bots/api#inputmedia
"""
assert not hasattr(input_media_audio, WIDTH)
assert not hasattr(input_media_document, WIDTH)
assert not hasattr(input_media_photo, WIDTH)
if hasattr(input_media_audio, WIDTH):
raise AssertionError
if hasattr(input_media_document, WIDTH):
raise AssertionError
if hasattr(input_media_photo, WIDTH):
raise AssertionError
assert hasattr(input_media_animation, WIDTH)
assert hasattr(input_media_video, WIDTH)
if not hasattr(input_media_animation, WIDTH):
raise AssertionError
if not hasattr(input_media_video, WIDTH):
raise AssertionError
def test_field_height():
"""
https://core.telegram.org/bots/api#inputmedia
"""
assert not hasattr(input_media_audio, HEIGHT)
assert not hasattr(input_media_document, HEIGHT)
assert not hasattr(input_media_photo, HEIGHT)
if hasattr(input_media_audio, HEIGHT):
raise AssertionError
if hasattr(input_media_document, HEIGHT):
raise AssertionError
if hasattr(input_media_photo, HEIGHT):
raise AssertionError
assert hasattr(input_media_animation, HEIGHT)
assert hasattr(input_media_video, HEIGHT)
if not hasattr(input_media_animation, HEIGHT):
raise AssertionError
if not hasattr(input_media_video, HEIGHT):
raise AssertionError

View file

@ -9,32 +9,45 @@ message = types.Message(**MESSAGE)
def test_export():
exported_chat = message.to_python()
assert isinstance(exported_chat, dict)
assert exported_chat == MESSAGE
if not isinstance(exported_chat, dict):
raise AssertionError
if exported_chat != MESSAGE:
raise AssertionError
def test_message_id():
# assert hash(message) == MESSAGE['message_id']
assert message.message_id == MESSAGE['message_id']
assert message['message_id'] == MESSAGE['message_id']
if message.message_id != MESSAGE['message_id']:
raise AssertionError
if message['message_id'] != MESSAGE['message_id']:
raise AssertionError
def test_from():
assert isinstance(message.from_user, types.User)
assert message.from_user == message['from']
if not isinstance(message.from_user, types.User):
raise AssertionError
if message.from_user != message['from']:
raise AssertionError
def test_chat():
assert isinstance(message.chat, types.Chat)
assert message.chat == message['chat']
if not isinstance(message.chat, types.Chat):
raise AssertionError
if message.chat != message['chat']:
raise AssertionError
def test_date():
assert isinstance(message.date, datetime.datetime)
assert int(message.date.timestamp()) == MESSAGE['date']
assert message.date == message['date']
if not isinstance(message.date, datetime.datetime):
raise AssertionError
if int(message.date.timestamp()) != MESSAGE['date']:
raise AssertionError
if message.date != message['date']:
raise AssertionError
def test_text():
assert message.text == MESSAGE['text']
assert message['text'] == MESSAGE['text']
if message.text != MESSAGE['text']:
raise AssertionError
if message['text'] != MESSAGE['text']:
raise AssertionError

View file

@ -7,22 +7,32 @@ photo = types.PhotoSize(**PHOTO)
def test_export():
exported = photo.to_python()
assert isinstance(exported, dict)
assert exported == PHOTO
if not isinstance(exported, dict):
raise AssertionError
if exported != PHOTO:
raise AssertionError
def test_file_id():
assert isinstance(photo.file_id, str)
assert photo.file_id == PHOTO['file_id']
if not isinstance(photo.file_id, str):
raise AssertionError
if photo.file_id != PHOTO['file_id']:
raise AssertionError
def test_file_size():
assert isinstance(photo.file_size, int)
assert photo.file_size == PHOTO['file_size']
if not isinstance(photo.file_size, int):
raise AssertionError
if photo.file_size != PHOTO['file_size']:
raise AssertionError
def test_size():
assert isinstance(photo.width, int)
assert isinstance(photo.height, int)
assert photo.width == PHOTO['width']
assert photo.height == PHOTO['height']
if not isinstance(photo.width, int):
raise AssertionError
if not isinstance(photo.height, int):
raise AssertionError
if photo.width != PHOTO['width']:
raise AssertionError
if photo.height != PHOTO['height']:
raise AssertionError

View file

@ -6,8 +6,10 @@ reply_keyboard = types.ReplyKeyboardMarkup(**REPLY_KEYBOARD_MARKUP)
def test_serialize():
assert reply_keyboard.to_python() == REPLY_KEYBOARD_MARKUP
if reply_keyboard.to_python() != REPLY_KEYBOARD_MARKUP:
raise AssertionError
def test_deserialize():
assert reply_keyboard.to_object(reply_keyboard.to_python()) == reply_keyboard
if reply_keyboard.to_object(reply_keyboard.to_python()) != reply_keyboard:
raise AssertionError

View file

@ -7,15 +7,20 @@ update = types.Update(**UPDATE)
def test_export():
exported = update.to_python()
assert isinstance(exported, dict)
assert exported == UPDATE
if not isinstance(exported, dict):
raise AssertionError
if exported != UPDATE:
raise AssertionError
def test_update_id():
assert isinstance(update.update_id, int)
if not isinstance(update.update_id, int):
raise AssertionError
# assert hash(update) == UPDATE['update_id']
assert update.update_id == UPDATE['update_id']
if update.update_id != UPDATE['update_id']:
raise AssertionError
def test_message():
assert isinstance(update.message, types.Message)
if not isinstance(update.message, types.Message):
raise AssertionError

View file

@ -9,41 +9,57 @@ user = types.User(**USER)
def test_export():
exported = user.to_python()
assert isinstance(exported, dict)
assert exported == USER
if not isinstance(exported, dict):
raise AssertionError
if exported != USER:
raise AssertionError
def test_id():
assert isinstance(user.id, int)
assert user.id == USER['id']
if not isinstance(user.id, int):
raise AssertionError
if user.id != USER['id']:
raise AssertionError
# assert hash(user) == USER['id']
def test_bot():
assert isinstance(user.is_bot, bool)
assert user.is_bot == USER['is_bot']
if not isinstance(user.is_bot, bool):
raise AssertionError
if user.is_bot != USER['is_bot']:
raise AssertionError
def test_name():
assert user.first_name == USER['first_name']
assert user.last_name == USER['last_name']
assert user.username == USER['username']
if user.first_name != USER['first_name']:
raise AssertionError
if user.last_name != USER['last_name']:
raise AssertionError
if user.username != USER['username']:
raise AssertionError
def test_language_code():
assert user.language_code == USER['language_code']
assert user.locale == Locale.parse(USER['language_code'], sep='-')
if user.language_code != USER['language_code']:
raise AssertionError
if user.locale != Locale.parse(USER['language_code'], sep='-'):
raise AssertionError
def test_full_name():
assert user.full_name == f"{USER['first_name']} {USER['last_name']}"
if user.full_name != f"{USER['first_name']} {USER['last_name']}":
raise AssertionError
def test_mention():
assert user.mention == f"@{USER['username']}"
assert user.get_mention('foo', as_html=False) == f"[foo](tg://user?id={USER['id']})"
assert user.get_mention('foo', as_html=True) == f"<a href=\"tg://user?id={USER['id']}\">foo</a>"
if user.mention != f"@{USER['username']}":
raise AssertionError
if user.get_mention('foo', as_html=False) != f"[foo](tg://user?id={USER['id']})":
raise AssertionError
if user.get_mention('foo', as_html=True) != f"<a href=\"tg://user?id={USER['id']}\">foo</a>":
raise AssertionError
def test_url():
assert user.url == f"tg://user?id={USER['id']}"
if user.url != f"tg://user?id={USER['id']}":
raise AssertionError