X Tutup
Skip to content

Commit 0f92450

Browse files
committed
Fix tests and minor changes
1 parent b20f5af commit 0f92450

File tree

10 files changed

+18
-41
lines changed

10 files changed

+18
-41
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ python:
44
- "2.7"
55
- "3.3"
66
- "3.4"
7+
- "nightly"
78
install:
89
- pip install coveralls
910
script:
10-
coverage run telegram_test.py
11+
coverage run make test
1112
after_success:
1213
coveralls
File renamed without changes.

Makefile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
help:
2-
@echo " clean remove unwanted stuff"
3-
@echo " lint check style with flake8"
4-
@echo " test run tests"
1+
.PHONY: clean test lint help
52

63
clean:
74
rm -fr build
@@ -14,4 +11,9 @@ lint:
1411
flake8 --doctests --max-complexity 10 telegram
1512

1613
test:
17-
python telegram_test.py
14+
@- $(foreach TEST, $(wildcard tests/test_*.py), python $(TEST))
15+
16+
help:
17+
@echo " clean remove unwanted stuff"
18+
@echo " lint check style with flake8"
19+
@echo " test run tests"

telegram_test.py

Lines changed: 0 additions & 30 deletions
This file was deleted.

tests/test_bot.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020

2121
import os
22+
import sys
23+
sys.path.append('.')
2224
import json
2325
import telegram
2426
import unittest
@@ -80,7 +82,7 @@ def testForwardMessage(self):
8082
def testSendPhoto(self):
8183
'''Test the telegram.Bot sendPhoto method'''
8284
print('Testing sendPhoto - File')
83-
message = self._bot.sendPhoto(photo=open('tests/telegram.png', 'rb'),
85+
message = self._bot.sendPhoto(photo=open('tests/data/telegram.png', 'rb'),
8486
caption='testSendPhoto',
8587
chat_id=12173560)
8688
self.assertTrue(self.is_json(message.to_json()))
@@ -122,7 +124,7 @@ def testSendGIFURLPhoto(self):
122124
def testSendAudio(self):
123125
'''Test the telegram.Bot sendAudio method'''
124126
print('Testing sendAudio - File')
125-
message = self._bot.sendAudio(audio=open('tests/telegram.mp3', 'rb'),
127+
message = self._bot.sendAudio(audio=open('tests/data/telegram.mp3', 'rb'),
126128
chat_id=12173560,
127129
performer='Leandro Toledo',
128130
title='Teste')
@@ -144,7 +146,7 @@ def testResendAudio(self):
144146
def testSendVoice(self):
145147
'''Test the telegram.Bot sendVoice method'''
146148
print('Testing sendVoice - File')
147-
message = self._bot.sendVoice(voice=open('tests/telegram.ogg', 'rb'),
149+
message = self._bot.sendVoice(voice=open('tests/data/telegram.ogg', 'rb'),
148150
chat_id=12173560)
149151
self.assertTrue(self.is_json(message.to_json()))
150152
self.assertEqual(9199, message.voice.file_size)
@@ -160,7 +162,7 @@ def testResendVoice(self):
160162
def testSendDocument(self):
161163
'''Test the telegram.Bot sendDocument method'''
162164
print('Testing sendDocument - File')
163-
message = self._bot.sendDocument(document=open('tests/telegram.png', 'rb'),
165+
message = self._bot.sendDocument(document=open('tests/data/telegram.png', 'rb'),
164166
chat_id=12173560)
165167
self.assertTrue(self.is_json(message.to_json()))
166168
self.assertEqual(12948, message.document.file_size)
@@ -184,7 +186,7 @@ def testResendDocument(self):
184186
def testSendVideo(self):
185187
'''Test the telegram.Bot sendVideo method'''
186188
print('Testing sendVideo - File')
187-
message = self._bot.sendVideo(video=open('tests/telegram.mp4', 'rb'),
189+
message = self._bot.sendVideo(video=open('tests/data/telegram.mp4', 'rb'),
188190
caption='testSendVideo',
189191
chat_id=12173560)
190192
self.assertTrue(self.is_json(message.to_json()))
@@ -229,3 +231,5 @@ def testGetUserProfilePhotos(self):
229231
upf = self._bot.getUserProfilePhotos(user_id=12173560)
230232
self.assertTrue(self.is_json(upf.to_json()))
231233
self.assertEqual(6547, upf.photos[0][0].file_size)
234+
235+
unittest.main()

0 commit comments

Comments
 (0)
X Tutup