Skip to content

Commit 880746b

Browse files
committed
Column width to 90 python-telegram-bot#259
1 parent 8ad1f33 commit 880746b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+211
-360
lines changed

setup.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ upload-dir = docs/build/html
1111

1212
[flake8]
1313
max-line-length = 99
14+
15+
[yapf]
16+
based_on_style = google
17+
column_limit = 99

tests/base.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ class BaseTest(object):
3636
def __init__(self, *args, **kwargs):
3737
super(BaseTest, self).__init__(*args, **kwargs)
3838

39-
bot = telegram.Bot(os.environ.get(
40-
'TOKEN', '133505823:AAHZFMHno3mzVLErU5b5jJvaeG--qUyLyG0'))
39+
bot = telegram.Bot(os.environ.get('TOKEN',
40+
'133505823:AAHZFMHno3mzVLErU5b5jJvaeG--qUyLyG0'))
4141
chat_id = os.environ.get('CHAT_ID', '12173560')
4242

4343
self._bot = bot
@@ -61,14 +61,17 @@ def is_dict(dictionary):
6161

6262

6363
class TestTimedOut(AssertionError):
64+
6465
def __init__(self, time_limit, frame):
6566
super(TestTimedOut, self).__init__('time_limit={0}'.format(time_limit))
6667
self.time_limit = time_limit
6768
self.frame = frame
6869

6970

7071
def timeout(time_limit):
72+
7173
def decorator(func):
74+
7275
def timed_out(_signum, frame):
7376
raise TestTimedOut(time_limit, frame)
7477

tests/test_audio.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ def test_error_send_audio_empty_file(self):
197197
del (json_dict['file_id'])
198198
json_dict['audio'] = open(os.devnull, 'rb')
199199

200-
self.assertRaises(telegram.TelegramError,
201-
lambda: self._bot.sendAudio(chat_id=self._chat_id,
202-
**json_dict))
200+
self.assertRaises(
201+
telegram.TelegramError,
202+
lambda: self._bot.sendAudio(chat_id=self._chat_id, **json_dict))
203203

204204
@flaky(3, 1)
205205
@timeout(10)
@@ -209,9 +209,9 @@ def test_error_send_audio_empty_file_id(self):
209209
del (json_dict['file_id'])
210210
json_dict['audio'] = ''
211211

212-
self.assertRaises(telegram.TelegramError,
213-
lambda: self._bot.sendAudio(chat_id=self._chat_id,
214-
**json_dict))
212+
self.assertRaises(
213+
telegram.TelegramError,
214+
lambda: self._bot.sendAudio(chat_id=self._chat_id, **json_dict))
215215

216216
@flaky(3, 1)
217217
@timeout(10)
@@ -221,9 +221,9 @@ def test_error_audio_without_required_args(self):
221221
del (json_dict['file_id'])
222222
del (json_dict['duration'])
223223

224-
self.assertRaises(TypeError,
225-
lambda: self._bot.sendAudio(chat_id=self._chat_id,
226-
**json_dict))
224+
self.assertRaises(
225+
TypeError,
226+
lambda: self._bot.sendAudio(chat_id=self._chat_id, **json_dict))
227227

228228

229229
if __name__ == '__main__':

tests/test_bot.py

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -54,26 +54,22 @@ def testGetMe(self):
5454
@flaky(3, 1)
5555
@timeout(10)
5656
def testSendMessage(self):
57-
message = self._bot.sendMessage(
58-
chat_id=self._chat_id,
59-
text='Моё судно на воздушной подушке полно угрей')
57+
message = self._bot.sendMessage(chat_id=self._chat_id,
58+
text='Моё судно на воздушной подушке полно угрей')
6059

6160
self.assertTrue(self.is_json(message.to_json()))
62-
self.assertEqual(message.text,
63-
u'Моё судно на воздушной подушке полно угрей')
61+
self.assertEqual(message.text, u'Моё судно на воздушной подушке полно угрей')
6462
self.assertTrue(isinstance(message.date, datetime))
6563

6664
@flaky(3, 1)
6765
@timeout(10)
6866
def testSilentSendMessage(self):
69-
message = self._bot.sendMessage(
70-
chat_id=self._chat_id,
71-
text='Моё судно на воздушной подушке полно угрей',
72-
disable_notification=True)
67+
message = self._bot.sendMessage(chat_id=self._chat_id,
68+
text='Моё судно на воздушной подушке полно угрей',
69+
disable_notification=True)
7370

7471
self.assertTrue(self.is_json(message.to_json()))
75-
self.assertEqual(message.text,
76-
u'Моё судно на воздушной подушке полно угрей')
72+
self.assertEqual(message.text, u'Моё судно на воздушной подушке полно угрей')
7773
self.assertTrue(isinstance(message.date, datetime))
7874

7975
@flaky(3, 1)
@@ -100,10 +96,9 @@ def testForwardMessage(self):
10096
@flaky(3, 1)
10197
@timeout(10)
10298
def testSendPhoto(self):
103-
message = self._bot.sendPhoto(
104-
photo=open('tests/data/telegram.png', 'rb'),
105-
caption='testSendPhoto',
106-
chat_id=self._chat_id)
99+
message = self._bot.sendPhoto(photo=open('tests/data/telegram.png', 'rb'),
100+
caption='testSendPhoto',
101+
chat_id=self._chat_id)
107102

108103
self.assertTrue(self.is_json(message.to_json()))
109104
self.assertEqual(message.photo[0].file_size, 1451)
@@ -112,11 +107,10 @@ def testSendPhoto(self):
112107
@flaky(3, 1)
113108
@timeout(10)
114109
def testSilentSendPhoto(self):
115-
message = self._bot.sendPhoto(
116-
photo=open('tests/data/telegram.png', 'rb'),
117-
caption='testSendPhoto',
118-
chat_id=self._chat_id,
119-
disable_notification=True)
110+
message = self._bot.sendPhoto(photo=open('tests/data/telegram.png', 'rb'),
111+
caption='testSendPhoto',
112+
chat_id=self._chat_id,
113+
disable_notification=True)
120114

121115
self.assertTrue(self.is_json(message.to_json()))
122116
self.assertEqual(message.photo[0].file_size, 1451)
@@ -130,9 +124,8 @@ def testResendPhoto(self):
130124
chat_id=self._chat_id)
131125

132126
self.assertTrue(self.is_json(message.to_json()))
133-
self.assertEqual(
134-
message.photo[0].file_id,
135-
'AgADAQADyKcxGx8j9Qdp6d-gpUsw4Gja1i8ABEVJsVqQk8LfJ3wAAgI')
127+
self.assertEqual(message.photo[0].file_id,
128+
'AgADAQADyKcxGx8j9Qdp6d-gpUsw4Gja1i8ABEVJsVqQk8LfJ3wAAgI')
136129

137130
@flaky(3, 1)
138131
@timeout(10)
@@ -177,8 +170,7 @@ def testSendBufferedReaderPhoto(self):
177170
@flaky(3, 1)
178171
@timeout(10)
179172
def testSendChatAction(self):
180-
self._bot.sendChatAction(action=telegram.ChatAction.TYPING,
181-
chat_id=self._chat_id)
173+
self._bot.sendChatAction(action=telegram.ChatAction.TYPING, chat_id=self._chat_id)
182174

183175
@flaky(3, 1)
184176
@timeout(10)
@@ -189,8 +181,7 @@ def testGetUserProfilePhotos(self):
189181
self.assertEqual(upf.photos[0][0].file_size, 12421)
190182

191183
def _test_invalid_token(self, token):
192-
self.assertRaisesRegexp(telegram.error.InvalidToken, 'Invalid token',
193-
telegram.Bot, token)
184+
self.assertRaisesRegexp(telegram.error.InvalidToken, 'Invalid token', telegram.Bot, token)
194185

195186
def testInvalidToken1(self):
196187
self._test_invalid_token('123')
@@ -202,14 +193,12 @@ def testInvalidToken3(self):
202193
self._test_invalid_token('12:')
203194

204195
def testUnauthToken(self):
205-
with self.assertRaisesRegexp(telegram.error.Unauthorized,
206-
'Unauthorized'):
196+
with self.assertRaisesRegexp(telegram.error.Unauthorized, 'Unauthorized'):
207197
bot = telegram.Bot('1234:abcd1234')
208198
bot.getMe()
209199

210200
def testInvalidSrvResp(self):
211-
with self.assertRaisesRegexp(telegram.TelegramError,
212-
'Invalid server response'):
201+
with self.assertRaisesRegexp(telegram.TelegramError, 'Invalid server response'):
213202
# bypass the valid token check
214203
bot = telegram.Bot.__new__(telegram.Bot)
215204
bot.base_url = 'https://api.telegram.org/bot{0}'.format('12')

tests/test_chat.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,7 @@ def setUp(self):
3434
self.title = 'ToledosPalaceBot - Group'
3535
self.type = 'group'
3636

37-
self.json_dict = {
38-
'id': self.id,
39-
'title': self.title,
40-
'type': self.type
41-
}
37+
self.json_dict = {'id': self.id, 'title': self.title, 'type': self.type}
4238

4339
def test_group_chat_de_json_empty_json(self):
4440
group_chat = telegram.Chat.de_json({})

tests/test_choseninlineresult.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ def test_choseninlineresult_de_json(self):
5252
result = telegram.ChosenInlineResult.de_json(self.json_dict)
5353

5454
self.assertEqual(result.result_id, self.result_id)
55-
self.assertDictEqual(result.from_user.to_dict(),
56-
self.from_user.to_dict())
55+
self.assertDictEqual(result.from_user.to_dict(), self.from_user.to_dict())
5756
self.assertEqual(result.query, self.query)
5857

5958
def test_choseninlineresult_to_json(self):

tests/test_document.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ def test_send_document_url_gif_file(self):
100100
@flaky(3, 1)
101101
@timeout(10)
102102
def test_send_document_resend(self):
103-
message = self._bot.sendDocument(chat_id=self._chat_id,
104-
document=self.document_file_id)
103+
message = self._bot.sendDocument(chat_id=self._chat_id, document=self.document_file_id)
105104

106105
document = message.document
107106

tests/test_file.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ def test_error_get_empty_file_id(self):
126126
del (json_dict['file_path'])
127127
del (json_dict['file_size'])
128128

129-
self.assertRaises(telegram.TelegramError,
130-
lambda: self._bot.getFile(**json_dict))
129+
self.assertRaises(telegram.TelegramError, lambda: self._bot.getFile(**json_dict))
131130

132131
def test_error_file_without_required_args(self):
133132
json_dict = self.json_dict

tests/test_filters.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ class FiltersTest(BaseTest, unittest.TestCase):
3535
"""This object represents Tests for MessageHandler.Filters"""
3636

3737
def setUp(self):
38-
self.message = Message(0, User(0, "Testuser"), datetime.now(),
39-
Chat(0, 'private'))
38+
self.message = Message(0, User(0, "Testuser"), datetime.now(), Chat(0, 'private'))
4039
self.update = Update(0, message=self.message)
4140

4241
def test_filters_text(self):

tests/test_forcereply.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,15 @@ def setUp(self):
3535
self.force_reply = True
3636
self.selective = True
3737

38-
self.json_dict = {
39-
'force_reply': self.force_reply,
40-
'selective': self.selective,
41-
}
38+
self.json_dict = {'force_reply': self.force_reply, 'selective': self.selective,}
4239

4340
def test_send_message_with_force_reply(self):
44-
message = self._bot.sendMessage(
45-
self._chat_id,
46-
'Моё судно на воздушной подушке полно угрей',
47-
reply_markup=telegram.ForceReply.de_json(self.json_dict))
41+
message = self._bot.sendMessage(self._chat_id,
42+
'Моё судно на воздушной подушке полно угрей',
43+
reply_markup=telegram.ForceReply.de_json(self.json_dict))
4844

4945
self.assertTrue(self.is_json(message.to_json()))
50-
self.assertEqual(message.text,
51-
u'Моё судно на воздушной подушке полно угрей')
46+
self.assertEqual(message.text, u'Моё судно на воздушной подушке полно угрей')
5247

5348
def test_force_reply_de_json(self):
5449
force_reply = telegram.ForceReply.de_json(self.json_dict)

0 commit comments

Comments
 (0)