flake8 revamp

- Use pre-commit v1.2.0 flake8
 - Make sure we're running flake8 on examples and tests
 - Fix what had to be fixed
This commit is contained in:
Noam Meltzer 2018-02-19 12:41:38 +02:00
parent 746ae0caf3
commit baec1bb554
44 changed files with 577 additions and 562 deletions

View file

@ -6,10 +6,10 @@
args: args:
- --diff - --diff
- repo: git://github.com/pre-commit/pre-commit-hooks - repo: git://github.com/pre-commit/pre-commit-hooks
sha: 78818b90cd694c29333ba54d38f9e60b6359ccfc sha: v1.2.0
hooks: hooks:
- id: flake8 - id: flake8
files: ^telegram/.*\.py$ exclude: ^(setup.py|docs/source/conf.py)$
- repo: git://github.com/pre-commit/mirrors-pylint - repo: git://github.com/pre-commit/mirrors-pylint
sha: v1.7.1 sha: v1.7.1
hooks: hooks:

View file

@ -18,8 +18,6 @@ bot.
""" """
from uuid import uuid4 from uuid import uuid4
import re
from telegram.utils.helpers import escape_markdown from telegram.utils.helpers import escape_markdown
from telegram import InlineQueryResultArticle, ParseMode, \ from telegram import InlineQueryResultArticle, ParseMode, \

View file

@ -283,7 +283,7 @@ class JobQueue(object):
self.logger.debug('Running job %s', job.name) self.logger.debug('Running job %s', job.name)
job.run(self.bot) job.run(self.bot)
except: except Exception:
self.logger.exception('An uncaught error was raised while executing job %s', self.logger.exception('An uncaught error was raised while executing job %s',
job.name) job.name)
else: else:

View file

@ -18,7 +18,7 @@
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
import os import os
import time import time
from datetime import datetime, timedelta from datetime import datetime
from platform import python_implementation from platform import python_implementation
import pytest import pytest
@ -552,7 +552,6 @@ class TestBot(object):
def test_restrict_chat_member(self, bot, channel_id): def test_restrict_chat_member(self, bot, channel_id):
# TODO: Add bot to supergroup so this can be tested properly # TODO: Add bot to supergroup so this can be tested properly
with pytest.raises(BadRequest, match='Method is available only for supergroups'): with pytest.raises(BadRequest, match='Method is available only for supergroups'):
until = datetime.now() + timedelta(seconds=30)
assert bot.restrict_chat_member(channel_id, assert bot.restrict_chat_member(channel_id,
95205500, 95205500,
until_date=datetime.now(), until_date=datetime.now(),

View file

@ -44,4 +44,4 @@ class TestConstants(object):
bad_caption = good_caption + 'Z' bad_caption = good_caption + 'Z'
with pytest.raises(BadRequest, message="Media_caption_too_long"): with pytest.raises(BadRequest, message="Media_caption_too_long"):
with open('tests/data/telegram.png', 'rb') as f: with open('tests/data/telegram.png', 'rb') as f:
bad_message = bot.send_photo(photo=f, caption=bad_caption, chat_id=chat_id) bot.send_photo(photo=f, caption=bad_caption, chat_id=chat_id)

View file

@ -88,8 +88,8 @@ class TestConversationHandler(object):
# Tests # Tests
def test_per_all_false(self): def test_per_all_false(self):
with pytest.raises(ValueError, match="can't all be 'False'"): with pytest.raises(ValueError, match="can't all be 'False'"):
handler = ConversationHandler(self.entry_points, self.states, self.fallbacks, ConversationHandler(self.entry_points, self.states, self.fallbacks,
per_chat=False, per_user=False, per_message=False) per_chat=False, per_user=False, per_message=False)
def test_conversation_handler(self, dp, bot, user1, user2): def test_conversation_handler(self, dp, bot, user1, user2):
handler = ConversationHandler(entry_points=self.entry_points, states=self.states, handler = ConversationHandler(entry_points=self.entry_points, states=self.states,

View file

@ -35,7 +35,8 @@ def dp2(bot):
class TestDispatcher(object): class TestDispatcher(object):
message_update = Update(1, message=Message(1, User(1, '', False), None, Chat(1, ''), text='Text')) message_update = Update(1,
message=Message(1, User(1, '', False), None, Chat(1, ''), text='Text'))
received = None received = None
count = 0 count = 0

View file

@ -48,8 +48,8 @@ class TestInlineKeyboardButton(object):
assert inline_keyboard_button.url == self.url assert inline_keyboard_button.url == self.url
assert inline_keyboard_button.callback_data == self.callback_data assert inline_keyboard_button.callback_data == self.callback_data
assert inline_keyboard_button.switch_inline_query == self.switch_inline_query assert inline_keyboard_button.switch_inline_query == self.switch_inline_query
assert inline_keyboard_button.switch_inline_query_current_chat == \ assert (inline_keyboard_button.switch_inline_query_current_chat ==
self.switch_inline_query_current_chat self.switch_inline_query_current_chat)
assert inline_keyboard_button.callback_game == self.callback_game assert inline_keyboard_button.callback_game == self.callback_game
assert inline_keyboard_button.pay == self.pay assert inline_keyboard_button.pay == self.pay
@ -60,9 +60,9 @@ class TestInlineKeyboardButton(object):
assert inline_keyboard_button_dict['text'] == inline_keyboard_button.text assert inline_keyboard_button_dict['text'] == inline_keyboard_button.text
assert inline_keyboard_button_dict['url'] == inline_keyboard_button.url assert inline_keyboard_button_dict['url'] == inline_keyboard_button.url
assert inline_keyboard_button_dict['callback_data'] == inline_keyboard_button.callback_data assert inline_keyboard_button_dict['callback_data'] == inline_keyboard_button.callback_data
assert inline_keyboard_button_dict['switch_inline_query'] == \ assert (inline_keyboard_button_dict['switch_inline_query'] ==
inline_keyboard_button.switch_inline_query inline_keyboard_button.switch_inline_query)
assert inline_keyboard_button_dict['switch_inline_query_current_chat'] == \ assert (inline_keyboard_button_dict['switch_inline_query_current_chat'] ==
inline_keyboard_button.switch_inline_query_current_chat inline_keyboard_button.switch_inline_query_current_chat)
assert inline_keyboard_button_dict['callback_game'] == inline_keyboard_button.callback_game assert inline_keyboard_button_dict['callback_game'] == inline_keyboard_button.callback_game
assert inline_keyboard_button_dict['pay'] == inline_keyboard_button.pay assert inline_keyboard_button_dict['pay'] == inline_keyboard_button.pay

View file

@ -25,16 +25,17 @@ from telegram import (InlineKeyboardMarkup, InlineQueryResultAudio, InlineQueryR
@pytest.fixture(scope='class') @pytest.fixture(scope='class')
def inline_query_result_article(): def inline_query_result_article():
return InlineQueryResultArticle(TestInlineQueryResultArticle.id, return InlineQueryResultArticle(
TestInlineQueryResultArticle.title, TestInlineQueryResultArticle.id,
input_message_content=TestInlineQueryResultArticle.input_message_content, TestInlineQueryResultArticle.title,
reply_markup=TestInlineQueryResultArticle.reply_markup, input_message_content=TestInlineQueryResultArticle.input_message_content,
url=TestInlineQueryResultArticle.url, reply_markup=TestInlineQueryResultArticle.reply_markup,
hide_url=TestInlineQueryResultArticle.hide_url, url=TestInlineQueryResultArticle.url,
description=TestInlineQueryResultArticle.description, hide_url=TestInlineQueryResultArticle.hide_url,
thumb_url=TestInlineQueryResultArticle.thumb_url, description=TestInlineQueryResultArticle.description,
thumb_height=TestInlineQueryResultArticle.thumb_height, thumb_url=TestInlineQueryResultArticle.thumb_url,
thumb_width=TestInlineQueryResultArticle.thumb_width) thumb_height=TestInlineQueryResultArticle.thumb_height,
thumb_width=TestInlineQueryResultArticle.thumb_width)
class TestInlineQueryResultArticle(object): class TestInlineQueryResultArticle(object):
@ -54,8 +55,8 @@ class TestInlineQueryResultArticle(object):
assert inline_query_result_article.type == self.type assert inline_query_result_article.type == self.type
assert inline_query_result_article.id == self.id assert inline_query_result_article.id == self.id
assert inline_query_result_article.title == self.title assert inline_query_result_article.title == self.title
assert inline_query_result_article.input_message_content.to_dict() == \ assert (inline_query_result_article.input_message_content.to_dict() ==
self.input_message_content.to_dict() self.input_message_content.to_dict())
assert inline_query_result_article.reply_markup.to_dict() == self.reply_markup.to_dict() assert inline_query_result_article.reply_markup.to_dict() == self.reply_markup.to_dict()
assert inline_query_result_article.url == self.url assert inline_query_result_article.url == self.url
assert inline_query_result_article.hide_url == self.hide_url assert inline_query_result_article.hide_url == self.hide_url
@ -71,20 +72,20 @@ class TestInlineQueryResultArticle(object):
assert inline_query_result_article_dict['type'] == inline_query_result_article.type assert inline_query_result_article_dict['type'] == inline_query_result_article.type
assert inline_query_result_article_dict['id'] == inline_query_result_article.id assert inline_query_result_article_dict['id'] == inline_query_result_article.id
assert inline_query_result_article_dict['title'] == inline_query_result_article.title assert inline_query_result_article_dict['title'] == inline_query_result_article.title
assert inline_query_result_article_dict['input_message_content'] == \ assert (inline_query_result_article_dict['input_message_content'] ==
inline_query_result_article.input_message_content.to_dict() inline_query_result_article.input_message_content.to_dict())
assert inline_query_result_article_dict['reply_markup'] == \ assert (inline_query_result_article_dict['reply_markup'] ==
inline_query_result_article.reply_markup.to_dict() inline_query_result_article.reply_markup.to_dict())
assert inline_query_result_article_dict['url'] == inline_query_result_article.url assert inline_query_result_article_dict['url'] == inline_query_result_article.url
assert inline_query_result_article_dict['hide_url'] == inline_query_result_article.hide_url assert inline_query_result_article_dict['hide_url'] == inline_query_result_article.hide_url
assert inline_query_result_article_dict['description'] == \ assert (inline_query_result_article_dict['description'] ==
inline_query_result_article.description inline_query_result_article.description)
assert inline_query_result_article_dict['thumb_url'] == \ assert (inline_query_result_article_dict['thumb_url'] ==
inline_query_result_article.thumb_url inline_query_result_article.thumb_url)
assert inline_query_result_article_dict['thumb_height'] == \ assert (inline_query_result_article_dict['thumb_height'] ==
inline_query_result_article.thumb_height inline_query_result_article.thumb_height)
assert inline_query_result_article_dict['thumb_width'] == \ assert (inline_query_result_article_dict['thumb_width'] ==
inline_query_result_article.thumb_width inline_query_result_article.thumb_width)
def test_equality(self): def test_equality(self):
a = InlineQueryResultArticle(self.id, self.title, self.input_message_content) a = InlineQueryResultArticle(self.id, self.title, self.input_message_content)

View file

@ -25,15 +25,16 @@ from telegram import (InlineKeyboardMarkup, InlineKeyboardButton, InlineQueryRes
@pytest.fixture(scope='class') @pytest.fixture(scope='class')
def inline_query_result_audio(): def inline_query_result_audio():
return InlineQueryResultAudio(TestInlineQueryResultAudio.id, return InlineQueryResultAudio(
TestInlineQueryResultAudio.audio_url, TestInlineQueryResultAudio.id,
TestInlineQueryResultAudio.title, TestInlineQueryResultAudio.audio_url,
performer=TestInlineQueryResultAudio.performer, TestInlineQueryResultAudio.title,
audio_duration=TestInlineQueryResultAudio.audio_duration, performer=TestInlineQueryResultAudio.performer,
caption=TestInlineQueryResultAudio.caption, audio_duration=TestInlineQueryResultAudio.audio_duration,
parse_mode=TestInlineQueryResultAudio.parse_mode, caption=TestInlineQueryResultAudio.caption,
input_message_content=TestInlineQueryResultAudio.input_message_content, parse_mode=TestInlineQueryResultAudio.parse_mode,
reply_markup=TestInlineQueryResultAudio.reply_markup) input_message_content=TestInlineQueryResultAudio.input_message_content,
reply_markup=TestInlineQueryResultAudio.reply_markup)
class TestInlineQueryResultAudio(object): class TestInlineQueryResultAudio(object):
@ -57,8 +58,8 @@ class TestInlineQueryResultAudio(object):
assert inline_query_result_audio.audio_duration == self.audio_duration assert inline_query_result_audio.audio_duration == self.audio_duration
assert inline_query_result_audio.caption == self.caption assert inline_query_result_audio.caption == self.caption
assert inline_query_result_audio.parse_mode == self.parse_mode assert inline_query_result_audio.parse_mode == self.parse_mode
assert inline_query_result_audio.input_message_content.to_dict() == \ assert (inline_query_result_audio.input_message_content.to_dict() ==
self.input_message_content.to_dict() self.input_message_content.to_dict())
assert inline_query_result_audio.reply_markup.to_dict() == self.reply_markup.to_dict() assert inline_query_result_audio.reply_markup.to_dict() == self.reply_markup.to_dict()
def test_to_dict(self, inline_query_result_audio): def test_to_dict(self, inline_query_result_audio):
@ -70,14 +71,14 @@ class TestInlineQueryResultAudio(object):
assert inline_query_result_audio_dict['audio_url'] == inline_query_result_audio.audio_url assert inline_query_result_audio_dict['audio_url'] == inline_query_result_audio.audio_url
assert inline_query_result_audio_dict['title'] == inline_query_result_audio.title assert inline_query_result_audio_dict['title'] == inline_query_result_audio.title
assert inline_query_result_audio_dict['performer'] == inline_query_result_audio.performer assert inline_query_result_audio_dict['performer'] == inline_query_result_audio.performer
assert inline_query_result_audio_dict['audio_duration'] == \ assert (inline_query_result_audio_dict['audio_duration'] ==
inline_query_result_audio.audio_duration inline_query_result_audio.audio_duration)
assert inline_query_result_audio_dict['caption'] == inline_query_result_audio.caption assert inline_query_result_audio_dict['caption'] == inline_query_result_audio.caption
assert inline_query_result_audio_dict['parse_mode'] == inline_query_result_audio.parse_mode assert inline_query_result_audio_dict['parse_mode'] == inline_query_result_audio.parse_mode
assert inline_query_result_audio_dict['input_message_content'] == \ assert (inline_query_result_audio_dict['input_message_content'] ==
inline_query_result_audio.input_message_content.to_dict() inline_query_result_audio.input_message_content.to_dict())
assert inline_query_result_audio_dict['reply_markup'] == \ assert (inline_query_result_audio_dict['reply_markup'] ==
inline_query_result_audio.reply_markup.to_dict() inline_query_result_audio.reply_markup.to_dict())
def test_equality(self): def test_equality(self):
a = InlineQueryResultAudio(self.id, self.audio_url, self.title) a = InlineQueryResultAudio(self.id, self.audio_url, self.title)

View file

@ -25,12 +25,13 @@ from telegram import (InputTextMessageContent, InlineQueryResultCachedAudio, Inl
@pytest.fixture(scope='class') @pytest.fixture(scope='class')
def inline_query_result_cached_audio(): def inline_query_result_cached_audio():
return InlineQueryResultCachedAudio(TestInlineQueryResultCachedAudio.id, return InlineQueryResultCachedAudio(
TestInlineQueryResultCachedAudio.audio_file_id, TestInlineQueryResultCachedAudio.id,
caption=TestInlineQueryResultCachedAudio.caption, TestInlineQueryResultCachedAudio.audio_file_id,
parse_mode=TestInlineQueryResultCachedAudio.parse_mode, caption=TestInlineQueryResultCachedAudio.caption,
input_message_content=TestInlineQueryResultCachedAudio.input_message_content, parse_mode=TestInlineQueryResultCachedAudio.parse_mode,
reply_markup=TestInlineQueryResultCachedAudio.reply_markup) input_message_content=TestInlineQueryResultCachedAudio.input_message_content,
reply_markup=TestInlineQueryResultCachedAudio.reply_markup)
class TestInlineQueryResultCachedAudio(object): class TestInlineQueryResultCachedAudio(object):
@ -48,28 +49,28 @@ class TestInlineQueryResultCachedAudio(object):
assert inline_query_result_cached_audio.audio_file_id == self.audio_file_id assert inline_query_result_cached_audio.audio_file_id == self.audio_file_id
assert inline_query_result_cached_audio.caption == self.caption assert inline_query_result_cached_audio.caption == self.caption
assert inline_query_result_cached_audio.parse_mode == self.parse_mode assert inline_query_result_cached_audio.parse_mode == self.parse_mode
assert inline_query_result_cached_audio.input_message_content.to_dict() == \ assert (inline_query_result_cached_audio.input_message_content.to_dict() ==
self.input_message_content.to_dict() self.input_message_content.to_dict())
assert inline_query_result_cached_audio.reply_markup.to_dict() == \ assert (inline_query_result_cached_audio.reply_markup.to_dict() ==
self.reply_markup.to_dict() self.reply_markup.to_dict())
def test_to_dict(self, inline_query_result_cached_audio): def test_to_dict(self, inline_query_result_cached_audio):
inline_query_result_cached_audio_dict = inline_query_result_cached_audio.to_dict() inline_query_result_cached_audio_dict = inline_query_result_cached_audio.to_dict()
assert isinstance(inline_query_result_cached_audio_dict, dict) assert isinstance(inline_query_result_cached_audio_dict, dict)
assert inline_query_result_cached_audio_dict['type'] == \ assert (inline_query_result_cached_audio_dict['type'] ==
inline_query_result_cached_audio.type inline_query_result_cached_audio.type)
assert inline_query_result_cached_audio_dict['id'] == inline_query_result_cached_audio.id assert inline_query_result_cached_audio_dict['id'] == inline_query_result_cached_audio.id
assert inline_query_result_cached_audio_dict['audio_file_id'] == \ assert (inline_query_result_cached_audio_dict['audio_file_id'] ==
inline_query_result_cached_audio.audio_file_id inline_query_result_cached_audio.audio_file_id)
assert inline_query_result_cached_audio_dict['caption'] == \ assert (inline_query_result_cached_audio_dict['caption'] ==
inline_query_result_cached_audio.caption inline_query_result_cached_audio.caption)
assert inline_query_result_cached_audio_dict['parse_mode'] == \ assert (inline_query_result_cached_audio_dict['parse_mode'] ==
inline_query_result_cached_audio.parse_mode inline_query_result_cached_audio.parse_mode)
assert inline_query_result_cached_audio_dict['input_message_content'] == \ assert (inline_query_result_cached_audio_dict['input_message_content'] ==
inline_query_result_cached_audio.input_message_content.to_dict() inline_query_result_cached_audio.input_message_content.to_dict())
assert inline_query_result_cached_audio_dict['reply_markup'] == \ assert (inline_query_result_cached_audio_dict['reply_markup'] ==
inline_query_result_cached_audio.reply_markup.to_dict() inline_query_result_cached_audio.reply_markup.to_dict())
def test_equality(self): def test_equality(self):
a = InlineQueryResultCachedAudio(self.id, self.audio_file_id) a = InlineQueryResultCachedAudio(self.id, self.audio_file_id)

View file

@ -25,14 +25,15 @@ from telegram import (InlineQueryResultCachedDocument, InlineKeyboardButton, Inl
@pytest.fixture(scope='class') @pytest.fixture(scope='class')
def inline_query_result_cached_document(): def inline_query_result_cached_document():
return InlineQueryResultCachedDocument(TestInlineQueryResultCachedDocument.id, return InlineQueryResultCachedDocument(
TestInlineQueryResultCachedDocument.title, TestInlineQueryResultCachedDocument.id,
TestInlineQueryResultCachedDocument.document_file_id, TestInlineQueryResultCachedDocument.title,
caption=TestInlineQueryResultCachedDocument.caption, TestInlineQueryResultCachedDocument.document_file_id,
parse_mode=TestInlineQueryResultCachedDocument.parse_mode, caption=TestInlineQueryResultCachedDocument.caption,
description=TestInlineQueryResultCachedDocument.description, parse_mode=TestInlineQueryResultCachedDocument.parse_mode,
input_message_content=TestInlineQueryResultCachedDocument.input_message_content, description=TestInlineQueryResultCachedDocument.description,
reply_markup=TestInlineQueryResultCachedDocument.reply_markup) input_message_content=TestInlineQueryResultCachedDocument.input_message_content,
reply_markup=TestInlineQueryResultCachedDocument.reply_markup)
class TestInlineQueryResultCachedDocument(object): class TestInlineQueryResultCachedDocument(object):
@ -54,33 +55,33 @@ class TestInlineQueryResultCachedDocument(object):
assert inline_query_result_cached_document.caption == self.caption assert inline_query_result_cached_document.caption == self.caption
assert inline_query_result_cached_document.parse_mode == self.parse_mode assert inline_query_result_cached_document.parse_mode == self.parse_mode
assert inline_query_result_cached_document.description == self.description assert inline_query_result_cached_document.description == self.description
assert inline_query_result_cached_document.input_message_content.to_dict() == \ assert (inline_query_result_cached_document.input_message_content.to_dict() ==
self.input_message_content.to_dict() self.input_message_content.to_dict())
assert inline_query_result_cached_document.reply_markup.to_dict() == \ assert (inline_query_result_cached_document.reply_markup.to_dict() ==
self.reply_markup.to_dict() self.reply_markup.to_dict())
def test_to_dict(self, inline_query_result_cached_document): def test_to_dict(self, inline_query_result_cached_document):
inline_query_result_cached_document_dict = inline_query_result_cached_document.to_dict() inline_query_result_cached_document_dict = inline_query_result_cached_document.to_dict()
assert isinstance(inline_query_result_cached_document_dict, dict) assert isinstance(inline_query_result_cached_document_dict, dict)
assert inline_query_result_cached_document_dict['id'] == \ assert (inline_query_result_cached_document_dict['id'] ==
inline_query_result_cached_document.id inline_query_result_cached_document.id)
assert inline_query_result_cached_document_dict['type'] == \ assert (inline_query_result_cached_document_dict['type'] ==
inline_query_result_cached_document.type inline_query_result_cached_document.type)
assert inline_query_result_cached_document_dict['document_file_id'] == \ assert (inline_query_result_cached_document_dict['document_file_id'] ==
inline_query_result_cached_document.document_file_id inline_query_result_cached_document.document_file_id)
assert inline_query_result_cached_document_dict['title'] == \ assert (inline_query_result_cached_document_dict['title'] ==
inline_query_result_cached_document.title inline_query_result_cached_document.title)
assert inline_query_result_cached_document_dict['caption'] == \ assert (inline_query_result_cached_document_dict['caption'] ==
inline_query_result_cached_document.caption inline_query_result_cached_document.caption)
assert inline_query_result_cached_document_dict['parse_mode'] == \ assert (inline_query_result_cached_document_dict['parse_mode'] ==
inline_query_result_cached_document.parse_mode inline_query_result_cached_document.parse_mode)
assert inline_query_result_cached_document_dict['description'] == \ assert (inline_query_result_cached_document_dict['description'] ==
inline_query_result_cached_document.description inline_query_result_cached_document.description)
assert inline_query_result_cached_document_dict['input_message_content'] == \ assert (inline_query_result_cached_document_dict['input_message_content'] ==
inline_query_result_cached_document.input_message_content.to_dict() inline_query_result_cached_document.input_message_content.to_dict())
assert inline_query_result_cached_document_dict['reply_markup'] == \ assert (inline_query_result_cached_document_dict['reply_markup'] ==
inline_query_result_cached_document.reply_markup.to_dict() inline_query_result_cached_document.reply_markup.to_dict())
def test_equality(self): def test_equality(self):
a = InlineQueryResultCachedDocument(self.id, self.title, self.document_file_id) a = InlineQueryResultCachedDocument(self.id, self.title, self.document_file_id)

View file

@ -25,13 +25,14 @@ from telegram import (InlineKeyboardButton, InputTextMessageContent, InlineQuery
@pytest.fixture(scope='class') @pytest.fixture(scope='class')
def inline_query_result_cached_gif(): def inline_query_result_cached_gif():
return InlineQueryResultCachedGif(TestInlineQueryResultCachedGif.id, return InlineQueryResultCachedGif(
TestInlineQueryResultCachedGif.gif_file_id, TestInlineQueryResultCachedGif.id,
title=TestInlineQueryResultCachedGif.title, TestInlineQueryResultCachedGif.gif_file_id,
caption=TestInlineQueryResultCachedGif.caption, title=TestInlineQueryResultCachedGif.title,
parse_mode=TestInlineQueryResultCachedGif.parse_mode, caption=TestInlineQueryResultCachedGif.caption,
input_message_content=TestInlineQueryResultCachedGif.input_message_content, parse_mode=TestInlineQueryResultCachedGif.parse_mode,
reply_markup=TestInlineQueryResultCachedGif.reply_markup) input_message_content=TestInlineQueryResultCachedGif.input_message_content,
reply_markup=TestInlineQueryResultCachedGif.reply_markup)
class TestInlineQueryResultCachedGif(object): class TestInlineQueryResultCachedGif(object):
@ -51,8 +52,8 @@ class TestInlineQueryResultCachedGif(object):
assert inline_query_result_cached_gif.title == self.title assert inline_query_result_cached_gif.title == self.title
assert inline_query_result_cached_gif.caption == self.caption assert inline_query_result_cached_gif.caption == self.caption
assert inline_query_result_cached_gif.parse_mode == self.parse_mode assert inline_query_result_cached_gif.parse_mode == self.parse_mode
assert inline_query_result_cached_gif.input_message_content.to_dict() == \ assert (inline_query_result_cached_gif.input_message_content.to_dict() ==
self.input_message_content.to_dict() self.input_message_content.to_dict())
assert inline_query_result_cached_gif.reply_markup.to_dict() == self.reply_markup.to_dict() assert inline_query_result_cached_gif.reply_markup.to_dict() == self.reply_markup.to_dict()
def test_to_dict(self, inline_query_result_cached_gif): def test_to_dict(self, inline_query_result_cached_gif):
@ -61,17 +62,17 @@ class TestInlineQueryResultCachedGif(object):
assert isinstance(inline_query_result_cached_gif_dict, dict) assert isinstance(inline_query_result_cached_gif_dict, dict)
assert inline_query_result_cached_gif_dict['type'] == inline_query_result_cached_gif.type assert inline_query_result_cached_gif_dict['type'] == inline_query_result_cached_gif.type
assert inline_query_result_cached_gif_dict['id'] == inline_query_result_cached_gif.id assert inline_query_result_cached_gif_dict['id'] == inline_query_result_cached_gif.id
assert inline_query_result_cached_gif_dict['gif_file_id'] == \ assert (inline_query_result_cached_gif_dict['gif_file_id'] ==
inline_query_result_cached_gif.gif_file_id inline_query_result_cached_gif.gif_file_id)
assert inline_query_result_cached_gif_dict['title'] == inline_query_result_cached_gif.title assert inline_query_result_cached_gif_dict['title'] == inline_query_result_cached_gif.title
assert inline_query_result_cached_gif_dict['caption'] == \ assert (inline_query_result_cached_gif_dict['caption'] ==
inline_query_result_cached_gif.caption inline_query_result_cached_gif.caption)
assert inline_query_result_cached_gif_dict['parse_mode'] == \ assert (inline_query_result_cached_gif_dict['parse_mode'] ==
inline_query_result_cached_gif.parse_mode inline_query_result_cached_gif.parse_mode)
assert inline_query_result_cached_gif_dict['input_message_content'] == \ assert (inline_query_result_cached_gif_dict['input_message_content'] ==
inline_query_result_cached_gif.input_message_content.to_dict() inline_query_result_cached_gif.input_message_content.to_dict())
assert inline_query_result_cached_gif_dict['reply_markup'] == \ assert (inline_query_result_cached_gif_dict['reply_markup'] ==
inline_query_result_cached_gif.reply_markup.to_dict() inline_query_result_cached_gif.reply_markup.to_dict())
def test_equality(self): def test_equality(self):
a = InlineQueryResultCachedGif(self.id, self.gif_file_id) a = InlineQueryResultCachedGif(self.id, self.gif_file_id)

View file

@ -25,13 +25,14 @@ from telegram import (InlineQueryResultCachedMpeg4Gif, InlineKeyboardButton,
@pytest.fixture(scope='class') @pytest.fixture(scope='class')
def inline_query_result_cached_mpeg4_gif(): def inline_query_result_cached_mpeg4_gif():
return InlineQueryResultCachedMpeg4Gif(TestInlineQueryResultCachedMpeg4Gif.id, return InlineQueryResultCachedMpeg4Gif(
TestInlineQueryResultCachedMpeg4Gif.mpeg4_file_id, TestInlineQueryResultCachedMpeg4Gif.id,
title=TestInlineQueryResultCachedMpeg4Gif.title, TestInlineQueryResultCachedMpeg4Gif.mpeg4_file_id,
caption=TestInlineQueryResultCachedMpeg4Gif.caption, title=TestInlineQueryResultCachedMpeg4Gif.title,
parse_mode=TestInlineQueryResultCachedMpeg4Gif.parse_mode, caption=TestInlineQueryResultCachedMpeg4Gif.caption,
input_message_content=TestInlineQueryResultCachedMpeg4Gif.input_message_content, parse_mode=TestInlineQueryResultCachedMpeg4Gif.parse_mode,
reply_markup=TestInlineQueryResultCachedMpeg4Gif.reply_markup) input_message_content=TestInlineQueryResultCachedMpeg4Gif.input_message_content,
reply_markup=TestInlineQueryResultCachedMpeg4Gif.reply_markup)
class TestInlineQueryResultCachedMpeg4Gif(object): class TestInlineQueryResultCachedMpeg4Gif(object):
@ -51,31 +52,31 @@ class TestInlineQueryResultCachedMpeg4Gif(object):
assert inline_query_result_cached_mpeg4_gif.title == self.title assert inline_query_result_cached_mpeg4_gif.title == self.title
assert inline_query_result_cached_mpeg4_gif.caption == self.caption assert inline_query_result_cached_mpeg4_gif.caption == self.caption
assert inline_query_result_cached_mpeg4_gif.parse_mode == self.parse_mode assert inline_query_result_cached_mpeg4_gif.parse_mode == self.parse_mode
assert inline_query_result_cached_mpeg4_gif.input_message_content.to_dict() == \ assert (inline_query_result_cached_mpeg4_gif.input_message_content.to_dict() ==
self.input_message_content.to_dict() self.input_message_content.to_dict())
assert inline_query_result_cached_mpeg4_gif.reply_markup.to_dict() == \ assert (inline_query_result_cached_mpeg4_gif.reply_markup.to_dict() ==
self.reply_markup.to_dict() self.reply_markup.to_dict())
def test_to_dict(self, inline_query_result_cached_mpeg4_gif): def test_to_dict(self, inline_query_result_cached_mpeg4_gif):
inline_query_result_cached_mpeg4_gif_dict = inline_query_result_cached_mpeg4_gif.to_dict() inline_query_result_cached_mpeg4_gif_dict = inline_query_result_cached_mpeg4_gif.to_dict()
assert isinstance(inline_query_result_cached_mpeg4_gif_dict, dict) assert isinstance(inline_query_result_cached_mpeg4_gif_dict, dict)
assert inline_query_result_cached_mpeg4_gif_dict['type'] == \ assert (inline_query_result_cached_mpeg4_gif_dict['type'] ==
inline_query_result_cached_mpeg4_gif.type inline_query_result_cached_mpeg4_gif.type)
assert inline_query_result_cached_mpeg4_gif_dict['id'] == \ assert (inline_query_result_cached_mpeg4_gif_dict['id'] ==
inline_query_result_cached_mpeg4_gif.id inline_query_result_cached_mpeg4_gif.id)
assert inline_query_result_cached_mpeg4_gif_dict['mpeg4_file_id'] == \ assert (inline_query_result_cached_mpeg4_gif_dict['mpeg4_file_id'] ==
inline_query_result_cached_mpeg4_gif.mpeg4_file_id inline_query_result_cached_mpeg4_gif.mpeg4_file_id)
assert inline_query_result_cached_mpeg4_gif_dict['title'] == \ assert (inline_query_result_cached_mpeg4_gif_dict['title'] ==
inline_query_result_cached_mpeg4_gif.title inline_query_result_cached_mpeg4_gif.title)
assert inline_query_result_cached_mpeg4_gif_dict['caption'] == \ assert (inline_query_result_cached_mpeg4_gif_dict['caption'] ==
inline_query_result_cached_mpeg4_gif.caption inline_query_result_cached_mpeg4_gif.caption)
assert inline_query_result_cached_mpeg4_gif_dict['parse_mode'] == \ assert (inline_query_result_cached_mpeg4_gif_dict['parse_mode'] ==
inline_query_result_cached_mpeg4_gif.parse_mode inline_query_result_cached_mpeg4_gif.parse_mode)
assert inline_query_result_cached_mpeg4_gif_dict['input_message_content'] == \ assert (inline_query_result_cached_mpeg4_gif_dict['input_message_content'] ==
inline_query_result_cached_mpeg4_gif.input_message_content.to_dict() inline_query_result_cached_mpeg4_gif.input_message_content.to_dict())
assert inline_query_result_cached_mpeg4_gif_dict['reply_markup'] == \ assert (inline_query_result_cached_mpeg4_gif_dict['reply_markup'] ==
inline_query_result_cached_mpeg4_gif.reply_markup.to_dict() inline_query_result_cached_mpeg4_gif.reply_markup.to_dict())
def test_equality(self): def test_equality(self):
a = InlineQueryResultCachedMpeg4Gif(self.id, self.mpeg4_file_id) a = InlineQueryResultCachedMpeg4Gif(self.id, self.mpeg4_file_id)

View file

@ -25,14 +25,15 @@ from telegram import (InputTextMessageContent, InlineQueryResultCachedPhoto, Inl
@pytest.fixture(scope='class') @pytest.fixture(scope='class')
def inline_query_result_cached_photo(): def inline_query_result_cached_photo():
return InlineQueryResultCachedPhoto(TestInlineQueryResultCachedPhoto.id, return InlineQueryResultCachedPhoto(
TestInlineQueryResultCachedPhoto.photo_file_id, TestInlineQueryResultCachedPhoto.id,
title=TestInlineQueryResultCachedPhoto.title, TestInlineQueryResultCachedPhoto.photo_file_id,
description=TestInlineQueryResultCachedPhoto.description, title=TestInlineQueryResultCachedPhoto.title,
caption=TestInlineQueryResultCachedPhoto.caption, description=TestInlineQueryResultCachedPhoto.description,
parse_mode=TestInlineQueryResultCachedPhoto.parse_mode, caption=TestInlineQueryResultCachedPhoto.caption,
input_message_content=TestInlineQueryResultCachedPhoto.input_message_content, parse_mode=TestInlineQueryResultCachedPhoto.parse_mode,
reply_markup=TestInlineQueryResultCachedPhoto.reply_markup) input_message_content=TestInlineQueryResultCachedPhoto.input_message_content,
reply_markup=TestInlineQueryResultCachedPhoto.reply_markup)
class TestInlineQueryResultCachedPhoto(object): class TestInlineQueryResultCachedPhoto(object):
@ -54,32 +55,32 @@ class TestInlineQueryResultCachedPhoto(object):
assert inline_query_result_cached_photo.description == self.description assert inline_query_result_cached_photo.description == self.description
assert inline_query_result_cached_photo.caption == self.caption assert inline_query_result_cached_photo.caption == self.caption
assert inline_query_result_cached_photo.parse_mode == self.parse_mode assert inline_query_result_cached_photo.parse_mode == self.parse_mode
assert inline_query_result_cached_photo.input_message_content.to_dict() == \ assert (inline_query_result_cached_photo.input_message_content.to_dict() ==
self.input_message_content.to_dict() self.input_message_content.to_dict())
assert inline_query_result_cached_photo.reply_markup.to_dict() == \ assert (inline_query_result_cached_photo.reply_markup.to_dict() ==
self.reply_markup.to_dict() self.reply_markup.to_dict())
def test_to_dict(self, inline_query_result_cached_photo): def test_to_dict(self, inline_query_result_cached_photo):
inline_query_result_cached_photo_dict = inline_query_result_cached_photo.to_dict() inline_query_result_cached_photo_dict = inline_query_result_cached_photo.to_dict()
assert isinstance(inline_query_result_cached_photo_dict, dict) assert isinstance(inline_query_result_cached_photo_dict, dict)
assert inline_query_result_cached_photo_dict['type'] == \ assert (inline_query_result_cached_photo_dict['type'] ==
inline_query_result_cached_photo.type inline_query_result_cached_photo.type)
assert inline_query_result_cached_photo_dict['id'] == inline_query_result_cached_photo.id assert inline_query_result_cached_photo_dict['id'] == inline_query_result_cached_photo.id
assert inline_query_result_cached_photo_dict['photo_file_id'] == \ assert (inline_query_result_cached_photo_dict['photo_file_id'] ==
inline_query_result_cached_photo.photo_file_id inline_query_result_cached_photo.photo_file_id)
assert inline_query_result_cached_photo_dict['title'] == \ assert (inline_query_result_cached_photo_dict['title'] ==
inline_query_result_cached_photo.title inline_query_result_cached_photo.title)
assert inline_query_result_cached_photo_dict['description'] == \ assert (inline_query_result_cached_photo_dict['description'] ==
inline_query_result_cached_photo.description inline_query_result_cached_photo.description)
assert inline_query_result_cached_photo_dict['caption'] == \ assert (inline_query_result_cached_photo_dict['caption'] ==
inline_query_result_cached_photo.caption inline_query_result_cached_photo.caption)
assert inline_query_result_cached_photo_dict['parse_mode'] == \ assert (inline_query_result_cached_photo_dict['parse_mode'] ==
inline_query_result_cached_photo.parse_mode inline_query_result_cached_photo.parse_mode)
assert inline_query_result_cached_photo_dict['input_message_content'] == \ assert (inline_query_result_cached_photo_dict['input_message_content'] ==
inline_query_result_cached_photo.input_message_content.to_dict() inline_query_result_cached_photo.input_message_content.to_dict())
assert inline_query_result_cached_photo_dict['reply_markup'] == \ assert (inline_query_result_cached_photo_dict['reply_markup'] ==
inline_query_result_cached_photo.reply_markup.to_dict() inline_query_result_cached_photo.reply_markup.to_dict())
def test_equality(self): def test_equality(self):
a = InlineQueryResultCachedPhoto(self.id, self.photo_file_id) a = InlineQueryResultCachedPhoto(self.id, self.photo_file_id)

View file

@ -26,10 +26,11 @@ from telegram import (InputTextMessageContent, InlineKeyboardButton,
@pytest.fixture(scope='class') @pytest.fixture(scope='class')
def inline_query_result_cached_sticker(): def inline_query_result_cached_sticker():
return InlineQueryResultCachedSticker(TestInlineQueryResultCachedSticker.id, return InlineQueryResultCachedSticker(
TestInlineQueryResultCachedSticker.sticker_file_id, TestInlineQueryResultCachedSticker.id,
input_message_content=TestInlineQueryResultCachedSticker.input_message_content, TestInlineQueryResultCachedSticker.sticker_file_id,
reply_markup=TestInlineQueryResultCachedSticker.reply_markup) input_message_content=TestInlineQueryResultCachedSticker.input_message_content,
reply_markup=TestInlineQueryResultCachedSticker.reply_markup)
class TestInlineQueryResultCachedSticker(object): class TestInlineQueryResultCachedSticker(object):
@ -43,25 +44,25 @@ class TestInlineQueryResultCachedSticker(object):
assert inline_query_result_cached_sticker.type == self.type assert inline_query_result_cached_sticker.type == self.type
assert inline_query_result_cached_sticker.id == self.id assert inline_query_result_cached_sticker.id == self.id
assert inline_query_result_cached_sticker.sticker_file_id == self.sticker_file_id assert inline_query_result_cached_sticker.sticker_file_id == self.sticker_file_id
assert inline_query_result_cached_sticker.input_message_content.to_dict() == \ assert (inline_query_result_cached_sticker.input_message_content.to_dict() ==
self.input_message_content.to_dict() self.input_message_content.to_dict())
assert inline_query_result_cached_sticker.reply_markup.to_dict() == \ assert (inline_query_result_cached_sticker.reply_markup.to_dict() ==
self.reply_markup.to_dict() self.reply_markup.to_dict())
def test_to_dict(self, inline_query_result_cached_sticker): def test_to_dict(self, inline_query_result_cached_sticker):
inline_query_result_cached_sticker_dict = inline_query_result_cached_sticker.to_dict() inline_query_result_cached_sticker_dict = inline_query_result_cached_sticker.to_dict()
assert isinstance(inline_query_result_cached_sticker_dict, dict) assert isinstance(inline_query_result_cached_sticker_dict, dict)
assert inline_query_result_cached_sticker_dict['type'] == \ assert (inline_query_result_cached_sticker_dict['type'] ==
inline_query_result_cached_sticker.type inline_query_result_cached_sticker.type)
assert inline_query_result_cached_sticker_dict['id'] == \ assert (inline_query_result_cached_sticker_dict['id'] ==
inline_query_result_cached_sticker.id inline_query_result_cached_sticker.id)
assert inline_query_result_cached_sticker_dict['sticker_file_id'] == \ assert (inline_query_result_cached_sticker_dict['sticker_file_id'] ==
inline_query_result_cached_sticker.sticker_file_id inline_query_result_cached_sticker.sticker_file_id)
assert inline_query_result_cached_sticker_dict['input_message_content'] == \ assert (inline_query_result_cached_sticker_dict['input_message_content'] ==
inline_query_result_cached_sticker.input_message_content.to_dict() inline_query_result_cached_sticker.input_message_content.to_dict())
assert inline_query_result_cached_sticker_dict['reply_markup'] == \ assert (inline_query_result_cached_sticker_dict['reply_markup'] ==
inline_query_result_cached_sticker.reply_markup.to_dict() inline_query_result_cached_sticker.reply_markup.to_dict())
def test_equality(self): def test_equality(self):
a = InlineQueryResultCachedSticker(self.id, self.sticker_file_id) a = InlineQueryResultCachedSticker(self.id, self.sticker_file_id)

View file

@ -25,14 +25,15 @@ from telegram import (InlineKeyboardMarkup, InlineKeyboardButton, InputTextMessa
@pytest.fixture(scope='class') @pytest.fixture(scope='class')
def inline_query_result_cached_video(): def inline_query_result_cached_video():
return InlineQueryResultCachedVideo(TestInlineQueryResultCachedVideo.id, return InlineQueryResultCachedVideo(
TestInlineQueryResultCachedVideo.video_file_id, TestInlineQueryResultCachedVideo.id,
TestInlineQueryResultCachedVideo.title, TestInlineQueryResultCachedVideo.video_file_id,
caption=TestInlineQueryResultCachedVideo.caption, TestInlineQueryResultCachedVideo.title,
parse_mode=TestInlineQueryResultCachedVideo.parse_mode, caption=TestInlineQueryResultCachedVideo.caption,
description=TestInlineQueryResultCachedVideo.description, parse_mode=TestInlineQueryResultCachedVideo.parse_mode,
input_message_content=TestInlineQueryResultCachedVideo.input_message_content, description=TestInlineQueryResultCachedVideo.description,
reply_markup=TestInlineQueryResultCachedVideo.reply_markup) input_message_content=TestInlineQueryResultCachedVideo.input_message_content,
reply_markup=TestInlineQueryResultCachedVideo.reply_markup)
class TestInlineQueryResultCachedVideo(object): class TestInlineQueryResultCachedVideo(object):
@ -54,32 +55,32 @@ class TestInlineQueryResultCachedVideo(object):
assert inline_query_result_cached_video.description == self.description assert inline_query_result_cached_video.description == self.description
assert inline_query_result_cached_video.caption == self.caption assert inline_query_result_cached_video.caption == self.caption
assert inline_query_result_cached_video.parse_mode == self.parse_mode assert inline_query_result_cached_video.parse_mode == self.parse_mode
assert inline_query_result_cached_video.input_message_content.to_dict() == \ assert (inline_query_result_cached_video.input_message_content.to_dict() ==
self.input_message_content.to_dict() self.input_message_content.to_dict())
assert inline_query_result_cached_video.reply_markup.to_dict() == \ assert (inline_query_result_cached_video.reply_markup.to_dict() ==
self.reply_markup.to_dict() self.reply_markup.to_dict())
def test_to_dict(self, inline_query_result_cached_video): def test_to_dict(self, inline_query_result_cached_video):
inline_query_result_cached_video_dict = inline_query_result_cached_video.to_dict() inline_query_result_cached_video_dict = inline_query_result_cached_video.to_dict()
assert isinstance(inline_query_result_cached_video_dict, dict) assert isinstance(inline_query_result_cached_video_dict, dict)
assert inline_query_result_cached_video_dict['type'] == \ assert (inline_query_result_cached_video_dict['type'] ==
inline_query_result_cached_video.type inline_query_result_cached_video.type)
assert inline_query_result_cached_video_dict['id'] == inline_query_result_cached_video.id assert inline_query_result_cached_video_dict['id'] == inline_query_result_cached_video.id
assert inline_query_result_cached_video_dict['video_file_id'] == \ assert (inline_query_result_cached_video_dict['video_file_id'] ==
inline_query_result_cached_video.video_file_id inline_query_result_cached_video.video_file_id)
assert inline_query_result_cached_video_dict['title'] == \ assert (inline_query_result_cached_video_dict['title'] ==
inline_query_result_cached_video.title inline_query_result_cached_video.title)
assert inline_query_result_cached_video_dict['description'] == \ assert (inline_query_result_cached_video_dict['description'] ==
inline_query_result_cached_video.description inline_query_result_cached_video.description)
assert inline_query_result_cached_video_dict['caption'] == \ assert (inline_query_result_cached_video_dict['caption'] ==
inline_query_result_cached_video.caption inline_query_result_cached_video.caption)
assert inline_query_result_cached_video_dict['parse_mode'] == \ assert (inline_query_result_cached_video_dict['parse_mode'] ==
inline_query_result_cached_video.parse_mode inline_query_result_cached_video.parse_mode)
assert inline_query_result_cached_video_dict['input_message_content'] == \ assert (inline_query_result_cached_video_dict['input_message_content'] ==
inline_query_result_cached_video.input_message_content.to_dict() inline_query_result_cached_video.input_message_content.to_dict())
assert inline_query_result_cached_video_dict['reply_markup'] == \ assert (inline_query_result_cached_video_dict['reply_markup'] ==
inline_query_result_cached_video.reply_markup.to_dict() inline_query_result_cached_video.reply_markup.to_dict())
def test_equality(self): def test_equality(self):
a = InlineQueryResultCachedVideo(self.id, self.video_file_id, self.title) a = InlineQueryResultCachedVideo(self.id, self.video_file_id, self.title)

View file

@ -25,13 +25,14 @@ from telegram import (InlineQueryResultCachedVoice, InlineKeyboardButton, Inline
@pytest.fixture(scope='class') @pytest.fixture(scope='class')
def inline_query_result_cached_voice(): def inline_query_result_cached_voice():
return InlineQueryResultCachedVoice(TestInlineQueryResultCachedVoice.id, return InlineQueryResultCachedVoice(
TestInlineQueryResultCachedVoice.voice_file_id, TestInlineQueryResultCachedVoice.id,
TestInlineQueryResultCachedVoice.title, TestInlineQueryResultCachedVoice.voice_file_id,
caption=TestInlineQueryResultCachedVoice.caption, TestInlineQueryResultCachedVoice.title,
parse_mode=TestInlineQueryResultCachedVoice.parse_mode, caption=TestInlineQueryResultCachedVoice.caption,
input_message_content=TestInlineQueryResultCachedVoice.input_message_content, parse_mode=TestInlineQueryResultCachedVoice.parse_mode,
reply_markup=TestInlineQueryResultCachedVoice.reply_markup) input_message_content=TestInlineQueryResultCachedVoice.input_message_content,
reply_markup=TestInlineQueryResultCachedVoice.reply_markup)
class TestInlineQueryResultCachedVoice(object): class TestInlineQueryResultCachedVoice(object):
@ -51,30 +52,30 @@ class TestInlineQueryResultCachedVoice(object):
assert inline_query_result_cached_voice.title == self.title assert inline_query_result_cached_voice.title == self.title
assert inline_query_result_cached_voice.caption == self.caption assert inline_query_result_cached_voice.caption == self.caption
assert inline_query_result_cached_voice.parse_mode == self.parse_mode assert inline_query_result_cached_voice.parse_mode == self.parse_mode
assert inline_query_result_cached_voice.input_message_content.to_dict() == \ assert (inline_query_result_cached_voice.input_message_content.to_dict() ==
self.input_message_content.to_dict() self.input_message_content.to_dict())
assert inline_query_result_cached_voice.reply_markup.to_dict() == \ assert (inline_query_result_cached_voice.reply_markup.to_dict() ==
self.reply_markup.to_dict() self.reply_markup.to_dict())
def test_to_dict(self, inline_query_result_cached_voice): def test_to_dict(self, inline_query_result_cached_voice):
inline_query_result_cached_voice_dict = inline_query_result_cached_voice.to_dict() inline_query_result_cached_voice_dict = inline_query_result_cached_voice.to_dict()
assert isinstance(inline_query_result_cached_voice_dict, dict) assert isinstance(inline_query_result_cached_voice_dict, dict)
assert inline_query_result_cached_voice_dict['type'] == \ assert (inline_query_result_cached_voice_dict['type'] ==
inline_query_result_cached_voice.type inline_query_result_cached_voice.type)
assert inline_query_result_cached_voice_dict['id'] == inline_query_result_cached_voice.id assert inline_query_result_cached_voice_dict['id'] == inline_query_result_cached_voice.id
assert inline_query_result_cached_voice_dict['voice_file_id'] == \ assert (inline_query_result_cached_voice_dict['voice_file_id'] ==
inline_query_result_cached_voice.voice_file_id inline_query_result_cached_voice.voice_file_id)
assert inline_query_result_cached_voice_dict['title'] == \ assert (inline_query_result_cached_voice_dict['title'] ==
inline_query_result_cached_voice.title inline_query_result_cached_voice.title)
assert inline_query_result_cached_voice_dict['caption'] == \ assert (inline_query_result_cached_voice_dict['caption'] ==
inline_query_result_cached_voice.caption inline_query_result_cached_voice.caption)
assert inline_query_result_cached_voice_dict['parse_mode'] == \ assert (inline_query_result_cached_voice_dict['parse_mode'] ==
inline_query_result_cached_voice.parse_mode inline_query_result_cached_voice.parse_mode)
assert inline_query_result_cached_voice_dict['input_message_content'] == \ assert (inline_query_result_cached_voice_dict['input_message_content'] ==
inline_query_result_cached_voice.input_message_content.to_dict() inline_query_result_cached_voice.input_message_content.to_dict())
assert inline_query_result_cached_voice_dict['reply_markup'] == \ assert (inline_query_result_cached_voice_dict['reply_markup'] ==
inline_query_result_cached_voice.reply_markup.to_dict() inline_query_result_cached_voice.reply_markup.to_dict())
def test_equality(self): def test_equality(self):
a = InlineQueryResultCachedVoice(self.id, self.voice_file_id, self.title) a = InlineQueryResultCachedVoice(self.id, self.voice_file_id, self.title)

View file

@ -25,15 +25,16 @@ from telegram import (InlineQueryResultVoice, InputTextMessageContent, InlineKey
@pytest.fixture(scope='class') @pytest.fixture(scope='class')
def inline_query_result_contact(): def inline_query_result_contact():
return InlineQueryResultContact(TestInlineQueryResultContact.id, return InlineQueryResultContact(
TestInlineQueryResultContact.phone_number, TestInlineQueryResultContact.id,
TestInlineQueryResultContact.first_name, TestInlineQueryResultContact.phone_number,
last_name=TestInlineQueryResultContact.last_name, TestInlineQueryResultContact.first_name,
thumb_url=TestInlineQueryResultContact.thumb_url, last_name=TestInlineQueryResultContact.last_name,
thumb_width=TestInlineQueryResultContact.thumb_width, thumb_url=TestInlineQueryResultContact.thumb_url,
thumb_height=TestInlineQueryResultContact.thumb_height, thumb_width=TestInlineQueryResultContact.thumb_width,
input_message_content=TestInlineQueryResultContact.input_message_content, thumb_height=TestInlineQueryResultContact.thumb_height,
reply_markup=TestInlineQueryResultContact.reply_markup) input_message_content=TestInlineQueryResultContact.input_message_content,
reply_markup=TestInlineQueryResultContact.reply_markup)
class TestInlineQueryResultContact(object): class TestInlineQueryResultContact(object):
@ -57,8 +58,8 @@ class TestInlineQueryResultContact(object):
assert inline_query_result_contact.thumb_url == self.thumb_url assert inline_query_result_contact.thumb_url == self.thumb_url
assert inline_query_result_contact.thumb_width == self.thumb_width assert inline_query_result_contact.thumb_width == self.thumb_width
assert inline_query_result_contact.thumb_height == self.thumb_height assert inline_query_result_contact.thumb_height == self.thumb_height
assert inline_query_result_contact.input_message_content.to_dict() == \ assert (inline_query_result_contact.input_message_content.to_dict() ==
self.input_message_content.to_dict() self.input_message_content.to_dict())
assert inline_query_result_contact.reply_markup.to_dict() == self.reply_markup.to_dict() assert inline_query_result_contact.reply_markup.to_dict() == self.reply_markup.to_dict()
def test_to_dict(self, inline_query_result_contact): def test_to_dict(self, inline_query_result_contact):
@ -67,22 +68,22 @@ class TestInlineQueryResultContact(object):
assert isinstance(inline_query_result_contact_dict, dict) assert isinstance(inline_query_result_contact_dict, dict)
assert inline_query_result_contact_dict['id'] == inline_query_result_contact.id assert inline_query_result_contact_dict['id'] == inline_query_result_contact.id
assert inline_query_result_contact_dict['type'] == inline_query_result_contact.type assert inline_query_result_contact_dict['type'] == inline_query_result_contact.type
assert inline_query_result_contact_dict['phone_number'] == \ assert (inline_query_result_contact_dict['phone_number'] ==
inline_query_result_contact.phone_number inline_query_result_contact.phone_number)
assert inline_query_result_contact_dict['first_name'] == \ assert (inline_query_result_contact_dict['first_name'] ==
inline_query_result_contact.first_name inline_query_result_contact.first_name)
assert inline_query_result_contact_dict['last_name'] == \ assert (inline_query_result_contact_dict['last_name'] ==
inline_query_result_contact.last_name inline_query_result_contact.last_name)
assert inline_query_result_contact_dict['thumb_url'] == \ assert (inline_query_result_contact_dict['thumb_url'] ==
inline_query_result_contact.thumb_url inline_query_result_contact.thumb_url)
assert inline_query_result_contact_dict['thumb_width'] == \ assert (inline_query_result_contact_dict['thumb_width'] ==
inline_query_result_contact.thumb_width inline_query_result_contact.thumb_width)
assert inline_query_result_contact_dict['thumb_height'] == \ assert (inline_query_result_contact_dict['thumb_height'] ==
inline_query_result_contact.thumb_height inline_query_result_contact.thumb_height)
assert inline_query_result_contact_dict['input_message_content'] == \ assert (inline_query_result_contact_dict['input_message_content'] ==
inline_query_result_contact.input_message_content.to_dict() inline_query_result_contact.input_message_content.to_dict())
assert inline_query_result_contact_dict['reply_markup'] == \ assert (inline_query_result_contact_dict['reply_markup'] ==
inline_query_result_contact.reply_markup.to_dict() inline_query_result_contact.reply_markup.to_dict())
def test_equality(self): def test_equality(self):
a = InlineQueryResultContact(self.id, self.phone_number, self.first_name) a = InlineQueryResultContact(self.id, self.phone_number, self.first_name)

View file

@ -25,18 +25,19 @@ from telegram import (InlineKeyboardButton, InputTextMessageContent, InlineQuery
@pytest.fixture(scope='class') @pytest.fixture(scope='class')
def inline_query_result_document(): def inline_query_result_document():
return InlineQueryResultDocument(TestInlineQueryResultDocument.id, return InlineQueryResultDocument(
TestInlineQueryResultDocument.document_url, TestInlineQueryResultDocument.id,
TestInlineQueryResultDocument.title, TestInlineQueryResultDocument.document_url,
TestInlineQueryResultDocument.mime_type, TestInlineQueryResultDocument.title,
caption=TestInlineQueryResultDocument.caption, TestInlineQueryResultDocument.mime_type,
parse_mode=TestInlineQueryResultDocument.parse_mode, caption=TestInlineQueryResultDocument.caption,
description=TestInlineQueryResultDocument.description, parse_mode=TestInlineQueryResultDocument.parse_mode,
thumb_url=TestInlineQueryResultDocument.thumb_url, description=TestInlineQueryResultDocument.description,
thumb_width=TestInlineQueryResultDocument.thumb_width, thumb_url=TestInlineQueryResultDocument.thumb_url,
thumb_height=TestInlineQueryResultDocument.thumb_height, thumb_width=TestInlineQueryResultDocument.thumb_width,
input_message_content=TestInlineQueryResultDocument.input_message_content, thumb_height=TestInlineQueryResultDocument.thumb_height,
reply_markup=TestInlineQueryResultDocument.reply_markup) input_message_content=TestInlineQueryResultDocument.input_message_content,
reply_markup=TestInlineQueryResultDocument.reply_markup)
class TestInlineQueryResultDocument(object): class TestInlineQueryResultDocument(object):
@ -66,8 +67,8 @@ class TestInlineQueryResultDocument(object):
assert inline_query_result_document.thumb_url == self.thumb_url assert inline_query_result_document.thumb_url == self.thumb_url
assert inline_query_result_document.thumb_width == self.thumb_width assert inline_query_result_document.thumb_width == self.thumb_width
assert inline_query_result_document.thumb_height == self.thumb_height assert inline_query_result_document.thumb_height == self.thumb_height
assert inline_query_result_document.input_message_content.to_dict() == \ assert (inline_query_result_document.input_message_content.to_dict() ==
self.input_message_content.to_dict() self.input_message_content.to_dict())
assert inline_query_result_document.reply_markup.to_dict() == self.reply_markup.to_dict() assert inline_query_result_document.reply_markup.to_dict() == self.reply_markup.to_dict()
def test_to_dict(self, inline_query_result_document): def test_to_dict(self, inline_query_result_document):
@ -76,26 +77,26 @@ class TestInlineQueryResultDocument(object):
assert isinstance(inline_query_result_document_dict, dict) assert isinstance(inline_query_result_document_dict, dict)
assert inline_query_result_document_dict['id'] == inline_query_result_document.id assert inline_query_result_document_dict['id'] == inline_query_result_document.id
assert inline_query_result_document_dict['type'] == inline_query_result_document.type assert inline_query_result_document_dict['type'] == inline_query_result_document.type
assert inline_query_result_document_dict['document_url'] == \ assert (inline_query_result_document_dict['document_url'] ==
inline_query_result_document.document_url inline_query_result_document.document_url)
assert inline_query_result_document_dict['title'] == inline_query_result_document.title assert inline_query_result_document_dict['title'] == inline_query_result_document.title
assert inline_query_result_document_dict['caption'] == inline_query_result_document.caption assert inline_query_result_document_dict['caption'] == inline_query_result_document.caption
assert inline_query_result_document_dict['parse_mode'] == \ assert (inline_query_result_document_dict['parse_mode'] ==
inline_query_result_document.parse_mode inline_query_result_document.parse_mode)
assert inline_query_result_document_dict['mime_type'] == \ assert (inline_query_result_document_dict['mime_type'] ==
inline_query_result_document.mime_type inline_query_result_document.mime_type)
assert inline_query_result_document_dict['description'] == \ assert (inline_query_result_document_dict['description'] ==
inline_query_result_document.description inline_query_result_document.description)
assert inline_query_result_document_dict['thumb_url'] == \ assert (inline_query_result_document_dict['thumb_url'] ==
inline_query_result_document.thumb_url inline_query_result_document.thumb_url)
assert inline_query_result_document_dict['thumb_width'] == \ assert (inline_query_result_document_dict['thumb_width'] ==
inline_query_result_document.thumb_width inline_query_result_document.thumb_width)
assert inline_query_result_document_dict['thumb_height'] == \ assert (inline_query_result_document_dict['thumb_height'] ==
inline_query_result_document.thumb_height inline_query_result_document.thumb_height)
assert inline_query_result_document_dict['input_message_content'] == \ assert (inline_query_result_document_dict['input_message_content'] ==
inline_query_result_document.input_message_content.to_dict() inline_query_result_document.input_message_content.to_dict())
assert inline_query_result_document_dict['reply_markup'] == \ assert (inline_query_result_document_dict['reply_markup'] ==
inline_query_result_document.reply_markup.to_dict() inline_query_result_document.reply_markup.to_dict())
def test_equality(self): def test_equality(self):
a = InlineQueryResultDocument(self.id, self.document_url, self.title, a = InlineQueryResultDocument(self.id, self.document_url, self.title,

View file

@ -40,8 +40,8 @@ class TestInlineQueryResultGame(object):
assert inline_query_result_game.type == self.type assert inline_query_result_game.type == self.type
assert inline_query_result_game.id == self.id assert inline_query_result_game.id == self.id
assert inline_query_result_game.game_short_name == self.game_short_name assert inline_query_result_game.game_short_name == self.game_short_name
assert inline_query_result_game.reply_markup.to_dict() == \ assert (inline_query_result_game.reply_markup.to_dict() ==
self.reply_markup.to_dict() self.reply_markup.to_dict())
def test_to_dict(self, inline_query_result_game): def test_to_dict(self, inline_query_result_game):
inline_query_result_game_dict = inline_query_result_game.to_dict() inline_query_result_game_dict = inline_query_result_game.to_dict()
@ -49,10 +49,10 @@ class TestInlineQueryResultGame(object):
assert isinstance(inline_query_result_game_dict, dict) assert isinstance(inline_query_result_game_dict, dict)
assert inline_query_result_game_dict['type'] == inline_query_result_game.type assert inline_query_result_game_dict['type'] == inline_query_result_game.type
assert inline_query_result_game_dict['id'] == inline_query_result_game.id assert inline_query_result_game_dict['id'] == inline_query_result_game.id
assert inline_query_result_game_dict['game_short_name'] == \ assert (inline_query_result_game_dict['game_short_name'] ==
inline_query_result_game.game_short_name inline_query_result_game.game_short_name)
assert inline_query_result_game_dict['reply_markup'] == \ assert (inline_query_result_game_dict['reply_markup'] ==
inline_query_result_game.reply_markup.to_dict() inline_query_result_game.reply_markup.to_dict())
def test_equality(self): def test_equality(self):
a = InlineQueryResultGame(self.id, self.game_short_name) a = InlineQueryResultGame(self.id, self.game_short_name)

View file

@ -25,17 +25,18 @@ from telegram import (InlineKeyboardButton, InputTextMessageContent, InlineQuery
@pytest.fixture(scope='class') @pytest.fixture(scope='class')
def inline_query_result_gif(): def inline_query_result_gif():
return InlineQueryResultGif(TestInlineQueryResultGif.id, return InlineQueryResultGif(
TestInlineQueryResultGif.gif_url, TestInlineQueryResultGif.id,
TestInlineQueryResultGif.thumb_url, TestInlineQueryResultGif.gif_url,
gif_width=TestInlineQueryResultGif.gif_width, TestInlineQueryResultGif.thumb_url,
gif_height=TestInlineQueryResultGif.gif_height, gif_width=TestInlineQueryResultGif.gif_width,
gif_duration=TestInlineQueryResultGif.gif_duration, gif_height=TestInlineQueryResultGif.gif_height,
title=TestInlineQueryResultGif.title, gif_duration=TestInlineQueryResultGif.gif_duration,
caption=TestInlineQueryResultGif.caption, title=TestInlineQueryResultGif.title,
parse_mode=TestInlineQueryResultGif.parse_mode, caption=TestInlineQueryResultGif.caption,
input_message_content=TestInlineQueryResultGif.input_message_content, parse_mode=TestInlineQueryResultGif.parse_mode,
reply_markup=TestInlineQueryResultGif.reply_markup) input_message_content=TestInlineQueryResultGif.input_message_content,
reply_markup=TestInlineQueryResultGif.reply_markup)
class TestInlineQueryResultGif(object): class TestInlineQueryResultGif(object):
@ -63,8 +64,8 @@ class TestInlineQueryResultGif(object):
assert inline_query_result_gif.title == self.title assert inline_query_result_gif.title == self.title
assert inline_query_result_gif.caption == self.caption assert inline_query_result_gif.caption == self.caption
assert inline_query_result_gif.parse_mode == self.parse_mode assert inline_query_result_gif.parse_mode == self.parse_mode
assert inline_query_result_gif.input_message_content.to_dict() == \ assert (inline_query_result_gif.input_message_content.to_dict() ==
self.input_message_content.to_dict() self.input_message_content.to_dict())
assert inline_query_result_gif.reply_markup.to_dict() == self.reply_markup.to_dict() assert inline_query_result_gif.reply_markup.to_dict() == self.reply_markup.to_dict()
def test_to_dict(self, inline_query_result_gif): def test_to_dict(self, inline_query_result_gif):
@ -81,10 +82,10 @@ class TestInlineQueryResultGif(object):
assert inline_query_result_gif_dict['title'] == inline_query_result_gif.title assert inline_query_result_gif_dict['title'] == inline_query_result_gif.title
assert inline_query_result_gif_dict['caption'] == inline_query_result_gif.caption assert inline_query_result_gif_dict['caption'] == inline_query_result_gif.caption
assert inline_query_result_gif_dict['parse_mode'] == inline_query_result_gif.parse_mode assert inline_query_result_gif_dict['parse_mode'] == inline_query_result_gif.parse_mode
assert inline_query_result_gif_dict['input_message_content'] == \ assert (inline_query_result_gif_dict['input_message_content'] ==
inline_query_result_gif.input_message_content.to_dict() inline_query_result_gif.input_message_content.to_dict())
assert inline_query_result_gif_dict['reply_markup'] == \ assert (inline_query_result_gif_dict['reply_markup'] ==
inline_query_result_gif.reply_markup.to_dict() inline_query_result_gif.reply_markup.to_dict())
def test_equality(self): def test_equality(self):
a = InlineQueryResultGif(self.id, self.gif_url, self.thumb_url) a = InlineQueryResultGif(self.id, self.gif_url, self.thumb_url)

View file

@ -25,16 +25,17 @@ from telegram import (InputTextMessageContent, InlineQueryResultLocation, Inline
@pytest.fixture(scope='class') @pytest.fixture(scope='class')
def inline_query_result_location(): def inline_query_result_location():
return InlineQueryResultLocation(TestInlineQueryResultLocation.id, return InlineQueryResultLocation(
TestInlineQueryResultLocation.latitude, TestInlineQueryResultLocation.id,
TestInlineQueryResultLocation.longitude, TestInlineQueryResultLocation.latitude,
TestInlineQueryResultLocation.title, TestInlineQueryResultLocation.longitude,
live_period=TestInlineQueryResultLocation.live_period, TestInlineQueryResultLocation.title,
thumb_url=TestInlineQueryResultLocation.thumb_url, live_period=TestInlineQueryResultLocation.live_period,
thumb_width=TestInlineQueryResultLocation.thumb_width, thumb_url=TestInlineQueryResultLocation.thumb_url,
thumb_height=TestInlineQueryResultLocation.thumb_height, thumb_width=TestInlineQueryResultLocation.thumb_width,
input_message_content=TestInlineQueryResultLocation.input_message_content, thumb_height=TestInlineQueryResultLocation.thumb_height,
reply_markup=TestInlineQueryResultLocation.reply_markup) input_message_content=TestInlineQueryResultLocation.input_message_content,
reply_markup=TestInlineQueryResultLocation.reply_markup)
class TestInlineQueryResultLocation(object): class TestInlineQueryResultLocation(object):
@ -60,8 +61,8 @@ class TestInlineQueryResultLocation(object):
assert inline_query_result_location.thumb_url == self.thumb_url assert inline_query_result_location.thumb_url == self.thumb_url
assert inline_query_result_location.thumb_width == self.thumb_width assert inline_query_result_location.thumb_width == self.thumb_width
assert inline_query_result_location.thumb_height == self.thumb_height assert inline_query_result_location.thumb_height == self.thumb_height
assert inline_query_result_location.input_message_content.to_dict() == \ assert (inline_query_result_location.input_message_content.to_dict() ==
self.input_message_content.to_dict() self.input_message_content.to_dict())
assert inline_query_result_location.reply_markup.to_dict() == self.reply_markup.to_dict() assert inline_query_result_location.reply_markup.to_dict() == self.reply_markup.to_dict()
def test_to_dict(self, inline_query_result_location): def test_to_dict(self, inline_query_result_location):
@ -70,23 +71,23 @@ class TestInlineQueryResultLocation(object):
assert isinstance(inline_query_result_location_dict, dict) assert isinstance(inline_query_result_location_dict, dict)
assert inline_query_result_location_dict['id'] == inline_query_result_location.id assert inline_query_result_location_dict['id'] == inline_query_result_location.id
assert inline_query_result_location_dict['type'] == inline_query_result_location.type assert inline_query_result_location_dict['type'] == inline_query_result_location.type
assert inline_query_result_location_dict['latitude'] == \ assert (inline_query_result_location_dict['latitude'] ==
inline_query_result_location.latitude inline_query_result_location.latitude)
assert inline_query_result_location_dict['longitude'] == \ assert (inline_query_result_location_dict['longitude'] ==
inline_query_result_location.longitude inline_query_result_location.longitude)
assert inline_query_result_location_dict['title'] == inline_query_result_location.title assert inline_query_result_location_dict['title'] == inline_query_result_location.title
assert inline_query_result_location_dict[ assert (inline_query_result_location_dict['live_period'] ==
'live_period'] == inline_query_result_location.live_period inline_query_result_location.live_period)
assert inline_query_result_location_dict['thumb_url'] == \ assert (inline_query_result_location_dict['thumb_url'] ==
inline_query_result_location.thumb_url inline_query_result_location.thumb_url)
assert inline_query_result_location_dict['thumb_width'] == \ assert (inline_query_result_location_dict['thumb_width'] ==
inline_query_result_location.thumb_width inline_query_result_location.thumb_width)
assert inline_query_result_location_dict['thumb_height'] == \ assert (inline_query_result_location_dict['thumb_height'] ==
inline_query_result_location.thumb_height inline_query_result_location.thumb_height)
assert inline_query_result_location_dict['input_message_content'] == \ assert (inline_query_result_location_dict['input_message_content'] ==
inline_query_result_location.input_message_content.to_dict() inline_query_result_location.input_message_content.to_dict())
assert inline_query_result_location_dict['reply_markup'] == \ assert (inline_query_result_location_dict['reply_markup'] ==
inline_query_result_location.reply_markup.to_dict() inline_query_result_location.reply_markup.to_dict())
def test_equality(self): def test_equality(self):
a = InlineQueryResultLocation(self.id, self.longitude, self.latitude, self.title) a = InlineQueryResultLocation(self.id, self.longitude, self.latitude, self.title)

View file

@ -25,17 +25,18 @@ from telegram import (InlineQueryResultMpeg4Gif, InlineKeyboardButton, InlineQue
@pytest.fixture(scope='class') @pytest.fixture(scope='class')
def inline_query_result_mpeg4_gif(): def inline_query_result_mpeg4_gif():
return InlineQueryResultMpeg4Gif(TestInlineQueryResultMpeg4Gif.id, return InlineQueryResultMpeg4Gif(
TestInlineQueryResultMpeg4Gif.mpeg4_url, TestInlineQueryResultMpeg4Gif.id,
TestInlineQueryResultMpeg4Gif.thumb_url, TestInlineQueryResultMpeg4Gif.mpeg4_url,
mpeg4_width=TestInlineQueryResultMpeg4Gif.mpeg4_width, TestInlineQueryResultMpeg4Gif.thumb_url,
mpeg4_height=TestInlineQueryResultMpeg4Gif.mpeg4_height, mpeg4_width=TestInlineQueryResultMpeg4Gif.mpeg4_width,
mpeg4_duration=TestInlineQueryResultMpeg4Gif.mpeg4_duration, mpeg4_height=TestInlineQueryResultMpeg4Gif.mpeg4_height,
title=TestInlineQueryResultMpeg4Gif.title, mpeg4_duration=TestInlineQueryResultMpeg4Gif.mpeg4_duration,
caption=TestInlineQueryResultMpeg4Gif.caption, title=TestInlineQueryResultMpeg4Gif.title,
parse_mode=TestInlineQueryResultMpeg4Gif.parse_mode, caption=TestInlineQueryResultMpeg4Gif.caption,
input_message_content=TestInlineQueryResultMpeg4Gif.input_message_content, parse_mode=TestInlineQueryResultMpeg4Gif.parse_mode,
reply_markup=TestInlineQueryResultMpeg4Gif.reply_markup) input_message_content=TestInlineQueryResultMpeg4Gif.input_message_content,
reply_markup=TestInlineQueryResultMpeg4Gif.reply_markup)
class TestInlineQueryResultMpeg4Gif(object): class TestInlineQueryResultMpeg4Gif(object):
@ -63,8 +64,8 @@ class TestInlineQueryResultMpeg4Gif(object):
assert inline_query_result_mpeg4_gif.title == self.title assert inline_query_result_mpeg4_gif.title == self.title
assert inline_query_result_mpeg4_gif.caption == self.caption assert inline_query_result_mpeg4_gif.caption == self.caption
assert inline_query_result_mpeg4_gif.parse_mode == self.parse_mode assert inline_query_result_mpeg4_gif.parse_mode == self.parse_mode
assert inline_query_result_mpeg4_gif.input_message_content.to_dict() == \ assert (inline_query_result_mpeg4_gif.input_message_content.to_dict() ==
self.input_message_content.to_dict() self.input_message_content.to_dict())
assert inline_query_result_mpeg4_gif.reply_markup.to_dict() == self.reply_markup.to_dict() assert inline_query_result_mpeg4_gif.reply_markup.to_dict() == self.reply_markup.to_dict()
def test_to_dict(self, inline_query_result_mpeg4_gif): def test_to_dict(self, inline_query_result_mpeg4_gif):
@ -73,25 +74,25 @@ class TestInlineQueryResultMpeg4Gif(object):
assert isinstance(inline_query_result_mpeg4_gif_dict, dict) assert isinstance(inline_query_result_mpeg4_gif_dict, dict)
assert inline_query_result_mpeg4_gif_dict['type'] == inline_query_result_mpeg4_gif.type assert inline_query_result_mpeg4_gif_dict['type'] == inline_query_result_mpeg4_gif.type
assert inline_query_result_mpeg4_gif_dict['id'] == inline_query_result_mpeg4_gif.id assert inline_query_result_mpeg4_gif_dict['id'] == inline_query_result_mpeg4_gif.id
assert inline_query_result_mpeg4_gif_dict['mpeg4_url'] == \ assert (inline_query_result_mpeg4_gif_dict['mpeg4_url'] ==
inline_query_result_mpeg4_gif.mpeg4_url inline_query_result_mpeg4_gif.mpeg4_url)
assert inline_query_result_mpeg4_gif_dict['mpeg4_width'] == \ assert (inline_query_result_mpeg4_gif_dict['mpeg4_width'] ==
inline_query_result_mpeg4_gif.mpeg4_width inline_query_result_mpeg4_gif.mpeg4_width)
assert inline_query_result_mpeg4_gif_dict['mpeg4_height'] == \ assert (inline_query_result_mpeg4_gif_dict['mpeg4_height'] ==
inline_query_result_mpeg4_gif.mpeg4_height inline_query_result_mpeg4_gif.mpeg4_height)
assert inline_query_result_mpeg4_gif_dict['mpeg4_duration'] == \ assert (inline_query_result_mpeg4_gif_dict['mpeg4_duration'] ==
inline_query_result_mpeg4_gif.mpeg4_duration inline_query_result_mpeg4_gif.mpeg4_duration)
assert inline_query_result_mpeg4_gif_dict['thumb_url'] == \ assert (inline_query_result_mpeg4_gif_dict['thumb_url'] ==
inline_query_result_mpeg4_gif.thumb_url inline_query_result_mpeg4_gif.thumb_url)
assert inline_query_result_mpeg4_gif_dict['title'] == inline_query_result_mpeg4_gif.title assert inline_query_result_mpeg4_gif_dict['title'] == inline_query_result_mpeg4_gif.title
assert inline_query_result_mpeg4_gif_dict['caption'] == \ assert (inline_query_result_mpeg4_gif_dict['caption'] ==
inline_query_result_mpeg4_gif.caption inline_query_result_mpeg4_gif.caption)
assert inline_query_result_mpeg4_gif_dict['parse_mode'] == \ assert (inline_query_result_mpeg4_gif_dict['parse_mode'] ==
inline_query_result_mpeg4_gif.parse_mode inline_query_result_mpeg4_gif.parse_mode)
assert inline_query_result_mpeg4_gif_dict['input_message_content'] == \ assert (inline_query_result_mpeg4_gif_dict['input_message_content'] ==
inline_query_result_mpeg4_gif.input_message_content.to_dict() inline_query_result_mpeg4_gif.input_message_content.to_dict())
assert inline_query_result_mpeg4_gif_dict['reply_markup'] == \ assert (inline_query_result_mpeg4_gif_dict['reply_markup'] ==
inline_query_result_mpeg4_gif.reply_markup.to_dict() inline_query_result_mpeg4_gif.reply_markup.to_dict())
def test_equality(self): def test_equality(self):
a = InlineQueryResultMpeg4Gif(self.id, self.mpeg4_url, self.thumb_url) a = InlineQueryResultMpeg4Gif(self.id, self.mpeg4_url, self.thumb_url)

View file

@ -25,17 +25,18 @@ from telegram import (InputTextMessageContent, InlineKeyboardButton, InlineKeybo
@pytest.fixture(scope='class') @pytest.fixture(scope='class')
def inline_query_result_photo(): def inline_query_result_photo():
return InlineQueryResultPhoto(TestInlineQueryResultPhoto.id, return InlineQueryResultPhoto(
TestInlineQueryResultPhoto.photo_url, TestInlineQueryResultPhoto.id,
TestInlineQueryResultPhoto.thumb_url, TestInlineQueryResultPhoto.photo_url,
photo_width=TestInlineQueryResultPhoto.photo_width, TestInlineQueryResultPhoto.thumb_url,
photo_height=TestInlineQueryResultPhoto.photo_height, photo_width=TestInlineQueryResultPhoto.photo_width,
title=TestInlineQueryResultPhoto.title, photo_height=TestInlineQueryResultPhoto.photo_height,
description=TestInlineQueryResultPhoto.description, title=TestInlineQueryResultPhoto.title,
caption=TestInlineQueryResultPhoto.caption, description=TestInlineQueryResultPhoto.description,
parse_mode=TestInlineQueryResultPhoto.parse_mode, caption=TestInlineQueryResultPhoto.caption,
input_message_content=TestInlineQueryResultPhoto.input_message_content, parse_mode=TestInlineQueryResultPhoto.parse_mode,
reply_markup=TestInlineQueryResultPhoto.reply_markup) input_message_content=TestInlineQueryResultPhoto.input_message_content,
reply_markup=TestInlineQueryResultPhoto.reply_markup)
class TestInlineQueryResultPhoto(object): class TestInlineQueryResultPhoto(object):
@ -63,8 +64,8 @@ class TestInlineQueryResultPhoto(object):
assert inline_query_result_photo.description == self.description assert inline_query_result_photo.description == self.description
assert inline_query_result_photo.caption == self.caption assert inline_query_result_photo.caption == self.caption
assert inline_query_result_photo.parse_mode == self.parse_mode assert inline_query_result_photo.parse_mode == self.parse_mode
assert inline_query_result_photo.input_message_content.to_dict() == \ assert (inline_query_result_photo.input_message_content.to_dict() ==
self.input_message_content.to_dict() self.input_message_content.to_dict())
assert inline_query_result_photo.reply_markup.to_dict() == self.reply_markup.to_dict() assert inline_query_result_photo.reply_markup.to_dict() == self.reply_markup.to_dict()
def test_to_dict(self, inline_query_result_photo): def test_to_dict(self, inline_query_result_photo):
@ -74,20 +75,20 @@ class TestInlineQueryResultPhoto(object):
assert inline_query_result_photo_dict['type'] == inline_query_result_photo.type assert inline_query_result_photo_dict['type'] == inline_query_result_photo.type
assert inline_query_result_photo_dict['id'] == inline_query_result_photo.id assert inline_query_result_photo_dict['id'] == inline_query_result_photo.id
assert inline_query_result_photo_dict['photo_url'] == inline_query_result_photo.photo_url assert inline_query_result_photo_dict['photo_url'] == inline_query_result_photo.photo_url
assert inline_query_result_photo_dict['photo_width'] == \ assert (inline_query_result_photo_dict['photo_width'] ==
inline_query_result_photo.photo_width inline_query_result_photo.photo_width)
assert inline_query_result_photo_dict['photo_height'] == \ assert (inline_query_result_photo_dict['photo_height'] ==
inline_query_result_photo.photo_height inline_query_result_photo.photo_height)
assert inline_query_result_photo_dict['thumb_url'] == inline_query_result_photo.thumb_url assert inline_query_result_photo_dict['thumb_url'] == inline_query_result_photo.thumb_url
assert inline_query_result_photo_dict['title'] == inline_query_result_photo.title assert inline_query_result_photo_dict['title'] == inline_query_result_photo.title
assert inline_query_result_photo_dict['description'] == \ assert (inline_query_result_photo_dict['description'] ==
inline_query_result_photo.description inline_query_result_photo.description)
assert inline_query_result_photo_dict['caption'] == inline_query_result_photo.caption assert inline_query_result_photo_dict['caption'] == inline_query_result_photo.caption
assert inline_query_result_photo_dict['parse_mode'] == inline_query_result_photo.parse_mode assert inline_query_result_photo_dict['parse_mode'] == inline_query_result_photo.parse_mode
assert inline_query_result_photo_dict['input_message_content'] == \ assert (inline_query_result_photo_dict['input_message_content'] ==
inline_query_result_photo.input_message_content.to_dict() inline_query_result_photo.input_message_content.to_dict())
assert inline_query_result_photo_dict['reply_markup'] == \ assert (inline_query_result_photo_dict['reply_markup'] ==
inline_query_result_photo.reply_markup.to_dict() inline_query_result_photo.reply_markup.to_dict())
def test_equality(self): def test_equality(self):
a = InlineQueryResultPhoto(self.id, self.photo_url, self.thumb_url) a = InlineQueryResultPhoto(self.id, self.photo_url, self.thumb_url)

View file

@ -25,17 +25,18 @@ from telegram import (InlineQueryResultVoice, InputTextMessageContent, InlineKey
@pytest.fixture(scope='class') @pytest.fixture(scope='class')
def inline_query_result_venue(): def inline_query_result_venue():
return InlineQueryResultVenue(TestInlineQueryResultVenue.id, return InlineQueryResultVenue(
TestInlineQueryResultVenue.latitude, TestInlineQueryResultVenue.id,
TestInlineQueryResultVenue.longitude, TestInlineQueryResultVenue.latitude,
TestInlineQueryResultVenue.title, TestInlineQueryResultVenue.longitude,
TestInlineQueryResultVenue.address, TestInlineQueryResultVenue.title,
foursquare_id=TestInlineQueryResultVenue.foursquare_id, TestInlineQueryResultVenue.address,
thumb_url=TestInlineQueryResultVenue.thumb_url, foursquare_id=TestInlineQueryResultVenue.foursquare_id,
thumb_width=TestInlineQueryResultVenue.thumb_width, thumb_url=TestInlineQueryResultVenue.thumb_url,
thumb_height=TestInlineQueryResultVenue.thumb_height, thumb_width=TestInlineQueryResultVenue.thumb_width,
input_message_content=TestInlineQueryResultVenue.input_message_content, thumb_height=TestInlineQueryResultVenue.thumb_height,
reply_markup=TestInlineQueryResultVenue.reply_markup) input_message_content=TestInlineQueryResultVenue.input_message_content,
reply_markup=TestInlineQueryResultVenue.reply_markup)
class TestInlineQueryResultVenue(object): class TestInlineQueryResultVenue(object):
@ -63,8 +64,8 @@ class TestInlineQueryResultVenue(object):
assert inline_query_result_venue.thumb_url == self.thumb_url assert inline_query_result_venue.thumb_url == self.thumb_url
assert inline_query_result_venue.thumb_width == self.thumb_width assert inline_query_result_venue.thumb_width == self.thumb_width
assert inline_query_result_venue.thumb_height == self.thumb_height assert inline_query_result_venue.thumb_height == self.thumb_height
assert inline_query_result_venue.input_message_content.to_dict() == \ assert (inline_query_result_venue.input_message_content.to_dict() ==
self.input_message_content.to_dict() self.input_message_content.to_dict())
assert inline_query_result_venue.reply_markup.to_dict() == self.reply_markup.to_dict() assert inline_query_result_venue.reply_markup.to_dict() == self.reply_markup.to_dict()
def test_to_dict(self, inline_query_result_venue): def test_to_dict(self, inline_query_result_venue):
@ -77,17 +78,17 @@ class TestInlineQueryResultVenue(object):
assert inline_query_result_venue_dict['longitude'] == inline_query_result_venue.longitude assert inline_query_result_venue_dict['longitude'] == inline_query_result_venue.longitude
assert inline_query_result_venue_dict['title'] == inline_query_result_venue.title assert inline_query_result_venue_dict['title'] == inline_query_result_venue.title
assert inline_query_result_venue_dict['address'] == inline_query_result_venue.address assert inline_query_result_venue_dict['address'] == inline_query_result_venue.address
assert inline_query_result_venue_dict['foursquare_id'] == \ assert (inline_query_result_venue_dict['foursquare_id'] ==
inline_query_result_venue.foursquare_id inline_query_result_venue.foursquare_id)
assert inline_query_result_venue_dict['thumb_url'] == inline_query_result_venue.thumb_url assert inline_query_result_venue_dict['thumb_url'] == inline_query_result_venue.thumb_url
assert inline_query_result_venue_dict['thumb_width'] == \ assert (inline_query_result_venue_dict['thumb_width'] ==
inline_query_result_venue.thumb_width inline_query_result_venue.thumb_width)
assert inline_query_result_venue_dict['thumb_height'] == \ assert (inline_query_result_venue_dict['thumb_height'] ==
inline_query_result_venue.thumb_height inline_query_result_venue.thumb_height)
assert inline_query_result_venue_dict['input_message_content'] == \ assert (inline_query_result_venue_dict['input_message_content'] ==
inline_query_result_venue.input_message_content.to_dict() inline_query_result_venue.input_message_content.to_dict())
assert inline_query_result_venue_dict['reply_markup'] == \ assert (inline_query_result_venue_dict['reply_markup'] ==
inline_query_result_venue.reply_markup.to_dict() inline_query_result_venue.reply_markup.to_dict())
def test_equality(self): def test_equality(self):
a = InlineQueryResultVenue(self.id, self.longitude, self.latitude, self.title, a = InlineQueryResultVenue(self.id, self.longitude, self.latitude, self.title,

View file

@ -25,19 +25,20 @@ from telegram import (InlineKeyboardButton, InputTextMessageContent, InlineQuery
@pytest.fixture(scope='class') @pytest.fixture(scope='class')
def inline_query_result_video(): def inline_query_result_video():
return InlineQueryResultVideo(TestInlineQueryResultVideo.id, return InlineQueryResultVideo(
TestInlineQueryResultVideo.video_url, TestInlineQueryResultVideo.id,
TestInlineQueryResultVideo.mime_type, TestInlineQueryResultVideo.video_url,
TestInlineQueryResultVideo.thumb_url, TestInlineQueryResultVideo.mime_type,
TestInlineQueryResultVideo.title, TestInlineQueryResultVideo.thumb_url,
video_width=TestInlineQueryResultVideo.video_width, TestInlineQueryResultVideo.title,
video_height=TestInlineQueryResultVideo.video_height, video_width=TestInlineQueryResultVideo.video_width,
video_duration=TestInlineQueryResultVideo.video_duration, video_height=TestInlineQueryResultVideo.video_height,
caption=TestInlineQueryResultVideo.caption, video_duration=TestInlineQueryResultVideo.video_duration,
parse_mode=TestInlineQueryResultVideo.parse_mode, caption=TestInlineQueryResultVideo.caption,
description=TestInlineQueryResultVideo.description, parse_mode=TestInlineQueryResultVideo.parse_mode,
input_message_content=TestInlineQueryResultVideo.input_message_content, description=TestInlineQueryResultVideo.description,
reply_markup=TestInlineQueryResultVideo.reply_markup) input_message_content=TestInlineQueryResultVideo.input_message_content,
reply_markup=TestInlineQueryResultVideo.reply_markup)
class TestInlineQueryResultVideo(object): class TestInlineQueryResultVideo(object):
@ -69,8 +70,8 @@ class TestInlineQueryResultVideo(object):
assert inline_query_result_video.description == self.description assert inline_query_result_video.description == self.description
assert inline_query_result_video.caption == self.caption assert inline_query_result_video.caption == self.caption
assert inline_query_result_video.parse_mode == self.parse_mode assert inline_query_result_video.parse_mode == self.parse_mode
assert inline_query_result_video.input_message_content.to_dict() == \ assert (inline_query_result_video.input_message_content.to_dict() ==
self.input_message_content.to_dict() self.input_message_content.to_dict())
assert inline_query_result_video.reply_markup.to_dict() == self.reply_markup.to_dict() assert inline_query_result_video.reply_markup.to_dict() == self.reply_markup.to_dict()
def test_to_dict(self, inline_query_result_video): def test_to_dict(self, inline_query_result_video):
@ -81,22 +82,22 @@ class TestInlineQueryResultVideo(object):
assert inline_query_result_video_dict['id'] == inline_query_result_video.id assert inline_query_result_video_dict['id'] == inline_query_result_video.id
assert inline_query_result_video_dict['video_url'] == inline_query_result_video.video_url assert inline_query_result_video_dict['video_url'] == inline_query_result_video.video_url
assert inline_query_result_video_dict['mime_type'] == inline_query_result_video.mime_type assert inline_query_result_video_dict['mime_type'] == inline_query_result_video.mime_type
assert inline_query_result_video_dict['video_width'] == \ assert (inline_query_result_video_dict['video_width'] ==
inline_query_result_video.video_width inline_query_result_video.video_width)
assert inline_query_result_video_dict['video_height'] == \ assert (inline_query_result_video_dict['video_height'] ==
inline_query_result_video.video_height inline_query_result_video.video_height)
assert inline_query_result_video_dict['video_duration'] == \ assert (inline_query_result_video_dict['video_duration'] ==
inline_query_result_video.video_duration inline_query_result_video.video_duration)
assert inline_query_result_video_dict['thumb_url'] == inline_query_result_video.thumb_url assert inline_query_result_video_dict['thumb_url'] == inline_query_result_video.thumb_url
assert inline_query_result_video_dict['title'] == inline_query_result_video.title assert inline_query_result_video_dict['title'] == inline_query_result_video.title
assert inline_query_result_video_dict['description'] == \ assert (inline_query_result_video_dict['description'] ==
inline_query_result_video.description inline_query_result_video.description)
assert inline_query_result_video_dict['caption'] == inline_query_result_video.caption assert inline_query_result_video_dict['caption'] == inline_query_result_video.caption
assert inline_query_result_video_dict['parse_mode'] == inline_query_result_video.parse_mode assert inline_query_result_video_dict['parse_mode'] == inline_query_result_video.parse_mode
assert inline_query_result_video_dict['input_message_content'] == \ assert (inline_query_result_video_dict['input_message_content'] ==
inline_query_result_video.input_message_content.to_dict() inline_query_result_video.input_message_content.to_dict())
assert inline_query_result_video_dict['reply_markup'] == \ assert (inline_query_result_video_dict['reply_markup'] ==
inline_query_result_video.reply_markup.to_dict() inline_query_result_video.reply_markup.to_dict())
def test_equality(self): def test_equality(self):
a = InlineQueryResultVideo(self.id, self.video_url, self.mime_type, a = InlineQueryResultVideo(self.id, self.video_url, self.mime_type,

View file

@ -25,15 +25,16 @@ from telegram import (InlineKeyboardButton, InputTextMessageContent, InlineQuery
@pytest.fixture(scope='class') @pytest.fixture(scope='class')
def inline_query_result_voice(): def inline_query_result_voice():
return InlineQueryResultVoice(type=TestInlineQueryResultVoice.type, return InlineQueryResultVoice(
id=TestInlineQueryResultVoice.id, type=TestInlineQueryResultVoice.type,
voice_url=TestInlineQueryResultVoice.voice_url, id=TestInlineQueryResultVoice.id,
title=TestInlineQueryResultVoice.title, voice_url=TestInlineQueryResultVoice.voice_url,
voice_duration=TestInlineQueryResultVoice.voice_duration, title=TestInlineQueryResultVoice.title,
caption=TestInlineQueryResultVoice.caption, voice_duration=TestInlineQueryResultVoice.voice_duration,
parse_mode=TestInlineQueryResultVoice.parse_mode, caption=TestInlineQueryResultVoice.caption,
input_message_content=TestInlineQueryResultVoice.input_message_content, parse_mode=TestInlineQueryResultVoice.parse_mode,
reply_markup=TestInlineQueryResultVoice.reply_markup) input_message_content=TestInlineQueryResultVoice.input_message_content,
reply_markup=TestInlineQueryResultVoice.reply_markup)
class TestInlineQueryResultVoice(object): class TestInlineQueryResultVoice(object):
@ -55,8 +56,8 @@ class TestInlineQueryResultVoice(object):
assert inline_query_result_voice.voice_duration == self.voice_duration assert inline_query_result_voice.voice_duration == self.voice_duration
assert inline_query_result_voice.caption == self.caption assert inline_query_result_voice.caption == self.caption
assert inline_query_result_voice.parse_mode == self.parse_mode assert inline_query_result_voice.parse_mode == self.parse_mode
assert inline_query_result_voice.input_message_content.to_dict() == \ assert (inline_query_result_voice.input_message_content.to_dict() ==
self.input_message_content.to_dict() self.input_message_content.to_dict())
assert inline_query_result_voice.reply_markup.to_dict() == self.reply_markup.to_dict() assert inline_query_result_voice.reply_markup.to_dict() == self.reply_markup.to_dict()
def test_to_dict(self, inline_query_result_voice): def test_to_dict(self, inline_query_result_voice):
@ -67,14 +68,14 @@ class TestInlineQueryResultVoice(object):
assert inline_query_result_voice_dict['id'] == inline_query_result_voice.id assert inline_query_result_voice_dict['id'] == inline_query_result_voice.id
assert inline_query_result_voice_dict['voice_url'] == inline_query_result_voice.voice_url assert inline_query_result_voice_dict['voice_url'] == inline_query_result_voice.voice_url
assert inline_query_result_voice_dict['title'] == inline_query_result_voice.title assert inline_query_result_voice_dict['title'] == inline_query_result_voice.title
assert inline_query_result_voice_dict['voice_duration'] == \ assert (inline_query_result_voice_dict['voice_duration'] ==
inline_query_result_voice.voice_duration inline_query_result_voice.voice_duration)
assert inline_query_result_voice_dict['caption'] == inline_query_result_voice.caption assert inline_query_result_voice_dict['caption'] == inline_query_result_voice.caption
assert inline_query_result_voice_dict['parse_mode'] == inline_query_result_voice.parse_mode assert inline_query_result_voice_dict['parse_mode'] == inline_query_result_voice.parse_mode
assert inline_query_result_voice_dict['input_message_content'] == \ assert (inline_query_result_voice_dict['input_message_content'] ==
inline_query_result_voice.input_message_content.to_dict() inline_query_result_voice.input_message_content.to_dict())
assert inline_query_result_voice_dict['reply_markup'] == \ assert (inline_query_result_voice_dict['reply_markup'] ==
inline_query_result_voice.reply_markup.to_dict() inline_query_result_voice.reply_markup.to_dict())
def test_equality(self): def test_equality(self):
a = InlineQueryResultVoice(self.id, self.voice_url, self.title) a = InlineQueryResultVoice(self.id, self.voice_url, self.title)

View file

@ -43,9 +43,9 @@ class TestInputContactMessageContent(object):
input_contact_message_content_dict = input_contact_message_content.to_dict() input_contact_message_content_dict = input_contact_message_content.to_dict()
assert isinstance(input_contact_message_content_dict, dict) assert isinstance(input_contact_message_content_dict, dict)
assert input_contact_message_content_dict['phone_number'] == \ assert (input_contact_message_content_dict['phone_number'] ==
input_contact_message_content.phone_number input_contact_message_content.phone_number)
assert input_contact_message_content_dict['first_name'] == \ assert (input_contact_message_content_dict['first_name'] ==
input_contact_message_content.first_name input_contact_message_content.first_name)
assert input_contact_message_content_dict['last_name'] == \ assert (input_contact_message_content_dict['last_name'] ==
input_contact_message_content.last_name input_contact_message_content.last_name)

View file

@ -43,9 +43,9 @@ class TestInputLocationMessageContent(object):
input_location_message_content_dict = input_location_message_content.to_dict() input_location_message_content_dict = input_location_message_content.to_dict()
assert isinstance(input_location_message_content_dict, dict) assert isinstance(input_location_message_content_dict, dict)
assert input_location_message_content_dict['latitude'] == \ assert (input_location_message_content_dict['latitude'] ==
input_location_message_content.latitude input_location_message_content.latitude)
assert input_location_message_content_dict['longitude'] == \ assert (input_location_message_content_dict['longitude'] ==
input_location_message_content.longitude input_location_message_content.longitude)
assert input_location_message_content_dict[ assert (input_location_message_content_dict['live_period'] ==
'live_period'] == input_location_message_content.live_period input_location_message_content.live_period)

View file

@ -20,8 +20,8 @@ import pytest
from flaky import flaky from flaky import flaky
from telegram import InputMediaVideo, InputMediaPhoto, Message from telegram import InputMediaVideo, InputMediaPhoto, Message
from .test_video import video, video_file from .test_video import video, video_file # noqa: F401
from .test_photo import _photo, photo_file, photo, thumb from .test_photo import _photo, photo_file, photo, thumb # noqa: F401
@pytest.fixture(scope='class') @pytest.fixture(scope='class')
@ -73,7 +73,7 @@ class TestInputMediaVideo(object):
assert input_media_video_dict['parse_mode'] == input_media_video.parse_mode assert input_media_video_dict['parse_mode'] == input_media_video.parse_mode
assert input_media_video_dict['supports_streaming'] == input_media_video.supports_streaming assert input_media_video_dict['supports_streaming'] == input_media_video.supports_streaming
def test_with_video(self, video): def test_with_video(self, video): # noqa: F811
# fixture found in test_video # fixture found in test_video
input_media_video = InputMediaVideo(video, caption="test 3") input_media_video = InputMediaVideo(video, caption="test 3")
assert input_media_video.type == self.type assert input_media_video.type == self.type
@ -83,7 +83,7 @@ class TestInputMediaVideo(object):
assert input_media_video.duration == video.duration assert input_media_video.duration == video.duration
assert input_media_video.caption == "test 3" assert input_media_video.caption == "test 3"
def test_error_with_file(self, video_file): def test_error_with_file(self, video_file): # noqa: F811
# fixture found in test_video # fixture found in test_video
with pytest.raises(ValueError, match="file_id, url or Video"): with pytest.raises(ValueError, match="file_id, url or Video"):
InputMediaVideo(video_file) InputMediaVideo(video_file)
@ -108,20 +108,20 @@ class TestInputMediaPhoto(object):
assert input_media_photo_dict['caption'] == input_media_photo.caption assert input_media_photo_dict['caption'] == input_media_photo.caption
assert input_media_photo_dict['parse_mode'] == input_media_photo.parse_mode assert input_media_photo_dict['parse_mode'] == input_media_photo.parse_mode
def test_with_photo(self, photo): def test_with_photo(self, photo): # noqa: F811
# fixture found in test_photo # fixture found in test_photo
imp = InputMediaPhoto(photo, caption="test 2") imp = InputMediaPhoto(photo, caption="test 2")
assert imp.type == self.type assert imp.type == self.type
assert imp.media == photo.file_id assert imp.media == photo.file_id
assert imp.caption == "test 2" assert imp.caption == "test 2"
def test_error_with_file(self, photo_file): def test_error_with_file(self, photo_file): # noqa: F811
# fixture found in test_photo # fixture found in test_photo
with pytest.raises(ValueError, match="file_id, url or PhotoSize"): with pytest.raises(ValueError, match="file_id, url or PhotoSize"):
InputMediaPhoto(photo_file) InputMediaPhoto(photo_file)
@pytest.fixture(scope='function') @pytest.fixture(scope='function') # noqa: F811
def media_group(photo, thumb): def media_group(photo, thumb):
return [InputMediaPhoto(photo, caption='photo `1`', parse_mode='Markdown'), return [InputMediaPhoto(photo, caption='photo `1`', parse_mode='Markdown'),
InputMediaPhoto(thumb, caption='<b>photo</b> 2', parse_mode='HTML')] InputMediaPhoto(thumb, caption='<b>photo</b> 2', parse_mode='HTML')]

View file

@ -24,9 +24,10 @@ from telegram import InputTextMessageContent, ParseMode
@pytest.fixture(scope='class') @pytest.fixture(scope='class')
def input_text_message_content(): def input_text_message_content():
return InputTextMessageContent(TestInputTextMessageContent.message_text, return InputTextMessageContent(
parse_mode=TestInputTextMessageContent.parse_mode, TestInputTextMessageContent.message_text,
disable_web_page_preview=TestInputTextMessageContent.disable_web_page_preview) parse_mode=TestInputTextMessageContent.parse_mode,
disable_web_page_preview=TestInputTextMessageContent.disable_web_page_preview)
class TestInputTextMessageContent(object): class TestInputTextMessageContent(object):
@ -43,9 +44,9 @@ class TestInputTextMessageContent(object):
input_text_message_content_dict = input_text_message_content.to_dict() input_text_message_content_dict = input_text_message_content.to_dict()
assert isinstance(input_text_message_content_dict, dict) assert isinstance(input_text_message_content_dict, dict)
assert input_text_message_content_dict['message_text'] == \ assert (input_text_message_content_dict['message_text'] ==
input_text_message_content.message_text input_text_message_content.message_text)
assert input_text_message_content_dict['parse_mode'] == \ assert (input_text_message_content_dict['parse_mode'] ==
input_text_message_content.parse_mode input_text_message_content.parse_mode)
assert input_text_message_content_dict['disable_web_page_preview'] == \ assert (input_text_message_content_dict['disable_web_page_preview'] ==
input_text_message_content.disable_web_page_preview input_text_message_content.disable_web_page_preview)

View file

@ -49,11 +49,11 @@ class TestInputVenueMessageContent(object):
input_venue_message_content_dict = input_venue_message_content.to_dict() input_venue_message_content_dict = input_venue_message_content.to_dict()
assert isinstance(input_venue_message_content_dict, dict) assert isinstance(input_venue_message_content_dict, dict)
assert input_venue_message_content_dict['latitude'] == \ assert (input_venue_message_content_dict['latitude'] ==
input_venue_message_content.latitude input_venue_message_content.latitude)
assert input_venue_message_content_dict['longitude'] == \ assert (input_venue_message_content_dict['longitude'] ==
input_venue_message_content.longitude input_venue_message_content.longitude)
assert input_venue_message_content_dict['title'] == input_venue_message_content.title assert input_venue_message_content_dict['title'] == input_venue_message_content.title
assert input_venue_message_content_dict['address'] == input_venue_message_content.address assert input_venue_message_content_dict['address'] == input_venue_message_content.address
assert input_venue_message_content_dict['foursquare_id'] == \ assert (input_venue_message_content_dict['foursquare_id'] ==
input_venue_message_content.foursquare_id input_venue_message_content.foursquare_id)

View file

@ -128,5 +128,5 @@ class TestInvoice(object):
with pytest.raises(TypeError): with pytest.raises(TypeError):
assert bot.send_invoice(chat_id, self.title, self.description, self.payload, assert bot.send_invoice(chat_id, self.title, self.description, self.payload,
provider_token, self.start_parameter, self.currency, provider_token, self.start_parameter, self.currency,
self.prices, provider_data={'a', 'b', 'c'}) self.prices, provider_data={'a', 'b', 'c'})

View file

@ -119,8 +119,8 @@ class TestMessageHandler(object):
def test_none_allowed(self): def test_none_allowed(self):
with pytest.raises(ValueError, match='are all False'): with pytest.raises(ValueError, match='are all False'):
handler = MessageHandler(None, self.callback_basic, message_updates=False, MessageHandler(None, self.callback_basic, message_updates=False,
channel_post_updates=False, edited_updates=False) channel_post_updates=False, edited_updates=False)
def test_with_filter(self, message): def test_with_filter(self, message):
handler = MessageHandler(Filters.command, self.callback_basic) handler = MessageHandler(Filters.command, self.callback_basic)

View file

@ -18,15 +18,12 @@
# along with this program. If not, see [http://www.gnu.org/licenses/]. # along with this program. If not, see [http://www.gnu.org/licenses/].
import inspect import inspect
import sys import sys
from collections import namedtuple
from platform import python_implementation from platform import python_implementation
import certifi import certifi
import pytest import pytest
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
sys.path.append('.')
from telegram.vendor.ptb_urllib3 import urllib3 from telegram.vendor.ptb_urllib3 import urllib3
import telegram import telegram
@ -50,8 +47,6 @@ def parse_table(h4):
table = find_next_sibling_until(h4, 'table', h4.find_next_sibling('h4')) table = find_next_sibling_until(h4, 'table', h4.find_next_sibling('h4'))
if not table: if not table:
return [] return []
head = [td.text for td in table.tr.find_all('td')]
# row = namedtuple('{}TableRow'.format(h4.text), ','.join(head))
t = [] t = []
for tr in table.find_all('tr')[1:]: for tr in table.find_all('tr')[1:]:
t.append([td.text for td in tr.find_all('td')]) t.append([td.text for td in tr.find_all('td')])

View file

@ -69,8 +69,8 @@ class TestPreCheckoutQuery(object):
assert isinstance(pre_checkout_query_dict, dict) assert isinstance(pre_checkout_query_dict, dict)
assert pre_checkout_query_dict['id'] == pre_checkout_query.id assert pre_checkout_query_dict['id'] == pre_checkout_query.id
assert pre_checkout_query_dict['invoice_payload'] == pre_checkout_query.invoice_payload assert pre_checkout_query_dict['invoice_payload'] == pre_checkout_query.invoice_payload
assert pre_checkout_query_dict['shipping_option_id'] == \ assert (pre_checkout_query_dict['shipping_option_id'] ==
pre_checkout_query.shipping_option_id pre_checkout_query.shipping_option_id)
assert pre_checkout_query_dict['currency'] == pre_checkout_query.currency assert pre_checkout_query_dict['currency'] == pre_checkout_query.currency
assert pre_checkout_query_dict['from'] == pre_checkout_query.from_user.to_dict() assert pre_checkout_query_dict['from'] == pre_checkout_query.from_user.to_dict()
assert pre_checkout_query_dict['order_info'] == pre_checkout_query.order_info.to_dict() assert pre_checkout_query_dict['order_info'] == pre_checkout_query.order_info.to_dict()

View file

@ -49,8 +49,9 @@ def false_update(request):
@pytest.fixture(scope='class') @pytest.fixture(scope='class')
def pre_checkout_query(): def pre_checkout_query():
return Update(1, pre_checkout_query=PreCheckoutQuery('id', User(1, 'test user', False), 'EUR', 223, return Update(1,
'invoice_payload')) pre_checkout_query=PreCheckoutQuery('id', User(1, 'test user', False),
'EUR', 223, 'invoice_payload'))
class TestPreCheckoutQueryHandler(object): class TestPreCheckoutQueryHandler(object):

View file

@ -150,8 +150,8 @@ class TestRegexHandler(object):
def test_none_allowed(self): def test_none_allowed(self):
with pytest.raises(ValueError, match='are all False'): with pytest.raises(ValueError, match='are all False'):
handler = RegexHandler('.*', self.callback_basic, message_updates=False, RegexHandler('.*', self.callback_basic, message_updates=False,
channel_post_updates=False, edited_updates=False) channel_post_updates=False, edited_updates=False)
def test_pass_user_or_chat_data(self, dp, message): def test_pass_user_or_chat_data(self, dp, message):
handler = RegexHandler('.*', self.callback_data_1, pass_user_data=True) handler = RegexHandler('.*', self.callback_data_1, pass_user_data=True)

View file

@ -63,12 +63,12 @@ class TestReplyKeyboardMarkup(object):
reply_keyboard_markup_dict = reply_keyboard_markup.to_dict() reply_keyboard_markup_dict = reply_keyboard_markup.to_dict()
assert isinstance(reply_keyboard_markup_dict, dict) assert isinstance(reply_keyboard_markup_dict, dict)
assert reply_keyboard_markup_dict['keyboard'][0][0] == \ assert (reply_keyboard_markup_dict['keyboard'][0][0] ==
reply_keyboard_markup.keyboard[0][0].to_dict() reply_keyboard_markup.keyboard[0][0].to_dict())
assert reply_keyboard_markup_dict['keyboard'][0][1] == \ assert (reply_keyboard_markup_dict['keyboard'][0][1] ==
reply_keyboard_markup.keyboard[0][1].to_dict() reply_keyboard_markup.keyboard[0][1].to_dict())
assert reply_keyboard_markup_dict['resize_keyboard'] == \ assert (reply_keyboard_markup_dict['resize_keyboard'] ==
reply_keyboard_markup.resize_keyboard reply_keyboard_markup.resize_keyboard)
assert reply_keyboard_markup_dict['one_time_keyboard'] == \ assert (reply_keyboard_markup_dict['one_time_keyboard'] ==
reply_keyboard_markup.one_time_keyboard reply_keyboard_markup.one_time_keyboard)
assert reply_keyboard_markup_dict['selective'] == reply_keyboard_markup.selective assert reply_keyboard_markup_dict['selective'] == reply_keyboard_markup.selective

View file

@ -43,6 +43,6 @@ class TestReplyKeyboardRemove(object):
def test_to_dict(self, reply_keyboard_remove): def test_to_dict(self, reply_keyboard_remove):
reply_keyboard_remove_dict = reply_keyboard_remove.to_dict() reply_keyboard_remove_dict = reply_keyboard_remove.to_dict()
assert reply_keyboard_remove_dict['remove_keyboard'] == \ assert (reply_keyboard_remove_dict['remove_keyboard'] ==
reply_keyboard_remove.remove_keyboard reply_keyboard_remove.remove_keyboard)
assert reply_keyboard_remove_dict['selective'] == reply_keyboard_remove.selective assert reply_keyboard_remove_dict['selective'] == reply_keyboard_remove.selective

View file

@ -49,9 +49,10 @@ def false_update(request):
@pytest.fixture(scope='class') @pytest.fixture(scope='class')
def shiping_query(): def shiping_query():
return Update(1, shipping_query=ShippingQuery(42, User(1, 'test user', False), 'invoice_payload', return Update(1,
ShippingAddress('EN', 'my_state', 'my_city', shipping_query=ShippingQuery(42, User(1, 'test user', False), 'invoice_payload',
'steer_1', '', 'post_code'))) ShippingAddress('EN', 'my_state', 'my_city',
'steer_1', '', 'post_code')))
class TestShippingQueryHandler(object): class TestShippingQueryHandler(object):

View file

@ -66,14 +66,14 @@ class TestSuccessfulPayment(object):
assert isinstance(successful_payment_dict, dict) assert isinstance(successful_payment_dict, dict)
assert successful_payment_dict['invoice_payload'] == successful_payment.invoice_payload assert successful_payment_dict['invoice_payload'] == successful_payment.invoice_payload
assert successful_payment_dict['shipping_option_id'] == \ assert (successful_payment_dict['shipping_option_id'] ==
successful_payment.shipping_option_id successful_payment.shipping_option_id)
assert successful_payment_dict['currency'] == successful_payment.currency assert successful_payment_dict['currency'] == successful_payment.currency
assert successful_payment_dict['order_info'] == successful_payment.order_info.to_dict() assert successful_payment_dict['order_info'] == successful_payment.order_info.to_dict()
assert successful_payment_dict['telegram_payment_charge_id'] == \ assert (successful_payment_dict['telegram_payment_charge_id'] ==
successful_payment.telegram_payment_charge_id successful_payment.telegram_payment_charge_id)
assert successful_payment_dict['provider_payment_charge_id'] == \ assert (successful_payment_dict['provider_payment_charge_id'] ==
successful_payment.provider_payment_charge_id successful_payment.provider_payment_charge_id)
def test_equality(self): def test_equality(self):
a = SuccessfulPayment(self.currency, self.total_amount, self.invoice_payload, a = SuccessfulPayment(self.currency, self.total_amount, self.invoice_payload,

View file

@ -105,7 +105,8 @@ class TestUpdater(object):
try: try:
# Now, we send an update to the server via urlopen # Now, we send an update to the server via urlopen
update = Update(1, message=Message(1, User(1, '', False), None, Chat(1, ''), text='Webhook')) update = Update(1, message=Message(1, User(1, '', False), None, Chat(1, ''),
text='Webhook'))
self._send_webhook_msg(ip, port, update.to_json(), 'TOKEN') self._send_webhook_msg(ip, port, update.to_json(), 'TOKEN')
sleep(.2) sleep(.2)
assert q.get(False) == update assert q.get(False) == update
@ -138,7 +139,8 @@ class TestUpdater(object):
sleep(.2) sleep(.2)
# Now, we send an update to the server via urlopen # Now, we send an update to the server via urlopen
update = Update(1, message=Message(1, User(1, '', False), None, Chat(1, ''), text='Webhook 2')) update = Update(1, message=Message(1, User(1, '', False), None, Chat(1, ''),
text='Webhook 2'))
self._send_webhook_msg(ip, port, update.to_json()) self._send_webhook_msg(ip, port, update.to_json())
sleep(.2) sleep(.2)
assert q.get(False) == update assert q.get(False) == update
@ -157,11 +159,9 @@ class TestUpdater(object):
assert self.attempts == retries assert self.attempts == retries
@pytest.mark.parametrize(('error', 'attempts'), @pytest.mark.parametrize(('error', 'attempts'),
argvalues=[ argvalues=[(TelegramError(''), 2),
(TelegramError(''), 2), (Unauthorized(''), 1),
(Unauthorized(''), 1), (InvalidToken(), 1)],
(InvalidToken(), 1)
],
ids=('TelegramError', 'Unauthorized', 'InvalidToken')) ids=('TelegramError', 'Unauthorized', 'InvalidToken'))
def test_bootstrap_retries_error(self, monkeypatch, updater, error, attempts): def test_bootstrap_retries_error(self, monkeypatch, updater, error, attempts):
retries = 1 retries = 1
@ -201,7 +201,7 @@ class TestUpdater(object):
# self._send_webhook_msg(ip, port, 'dummy-payload', content_len=None) # self._send_webhook_msg(ip, port, 'dummy-payload', content_len=None)
# assert excinfo.value.code == 411 # assert excinfo.value.code == 411
with pytest.raises(HTTPError) as ctx: with pytest.raises(HTTPError):
self._send_webhook_msg(ip, port, 'dummy-payload', content_len='not-a-number') self._send_webhook_msg(ip, port, 'dummy-payload', content_len='not-a-number')
assert excinfo.value.code == 403 assert excinfo.value.code == 403