@@ -47,21 +47,17 @@ def setUpClass(cls):
4747 cls .thumb = video .thumb
4848 cls .mime_type = video .mime_type
4949 cls .file_size = video .file_size
50-
51-
52- def setUp (self ):
53- self .video_file = open ('tests/data/telegram.mp4' , 'rb' )
54- self .video_file_url = 'https://python-telegram-bot.org/static/website/telegram.mp4'
55- self .thumb_from_url = telegram .PhotoSize .de_json ({
50+ cls .video_file_url = 'https://python-telegram-bot.org/static/website/telegram.mp4'
51+ cls .caption = u'VideoTest - Caption'
52+ cls .thumb_from_url = telegram .PhotoSize .de_json ({
5653 'file_id' : 'AAQEABPZU2EZAAQ_tPcvcRTF4i1GAQABAg' ,
5754 'file_size' : 645 ,
5855 'height' : 90 ,
5956 'width' : 51
60- }, self ._bot )
61-
62- # caption is part of sendVideo method but not Video object
63- self .caption = u'VideoTest - Caption'
57+ }, cls ._bot )
6458
59+ def setUp (self ):
60+ self .video_file = open ('tests/data/telegram.mp4' , 'rb' )
6561 self .json_dict = {
6662 'file_id' : self .video_file_id ,
6763 'width' : self .width ,
@@ -75,18 +71,8 @@ def setUp(self):
7571 @flaky (3 , 1 )
7672 @timeout (10 )
7773 def test_send_video_required_args_only (self ):
78- message = self ._bot .sendVideo (self ._chat_id , self .video_file , timeout = 10 )
79-
80- video = message .video
81-
82- self .assertTrue (isinstance (video .file_id , str ))
83- self .assertNotEqual (video .file_id , None )
84- self .assertEqual (video .width , self .width )
85- self .assertEqual (video .height , self .height )
86- self .assertEqual (video .duration , self .duration )
87- self .assertEqual (video .thumb , self .thumb )
88- self .assertEqual (video .mime_type , 'video/mp4' )
89- self .assertEqual (video .file_size , self .file_size )
74+ # obsolete since it's done in the setUpClass
75+ self .assertEqual (True , True )
9076
9177 @flaky (3 , 1 )
9278 @timeout (10 )
@@ -106,33 +92,17 @@ def test_send_video_all_args(self):
10692 self .assertEqual (video .height , self .height )
10793 self .assertEqual (video .duration , self .duration )
10894 self .assertEqual (video .thumb , self .thumb )
109- self .assertEqual (video .mime_type , 'video/mp4' )
95+ self .assertEqual (video .mime_type , self . mime_type )
11096 self .assertEqual (video .file_size , self .file_size )
11197
11298 self .assertEqual (message .caption , self .caption )
11399
114100 @flaky (3 , 1 )
115101 @timeout (10 )
116102 def test_send_video_mp4_file (self ):
117- message = self ._bot .sendVideo (
118- chat_id = self ._chat_id ,
119- video = self .video_file ,
120- timeout = 10 ,
121- duration = self .duration ,
122- caption = self .caption )
123-
124- video = message .video
125-
126- self .assertTrue (isinstance (video .file_id , str ))
127- self .assertNotEqual (video .file_id , None )
128- self .assertEqual (video .width , self .width )
129- self .assertEqual (video .height , self .height )
130- self .assertEqual (video .duration , self .duration )
131- self .assertEqual (video .thumb , self .thumb )
132- self .assertEqual (video .mime_type , 'video/mp4' )
133- self .assertEqual (video .file_size , self .file_size )
103+ # identical to all_args so obsolete
104+ self .assertEqual (True , True )
134105
135- self .assertEqual (message .caption , self .caption )
136106
137107 @flaky (3 , 1 )
138108 @timeout (10 )
@@ -153,7 +123,7 @@ def test_send_video_mp4_file_with_custom_filename(self):
153123 self .assertEqual (video .height , self .height )
154124 self .assertEqual (video .duration , self .duration )
155125 self .assertEqual (video .thumb , self .thumb )
156- self .assertEqual (video .mime_type , 'video/mp4' )
126+ self .assertEqual (video .mime_type , self . mime_type )
157127 self .assertEqual (video .file_size , self .file_size )
158128
159129 self .assertEqual (message .caption , self .caption )
@@ -165,7 +135,6 @@ def test_send_video_mp4_file_url(self):
165135 chat_id = self ._chat_id ,
166136 video = self .video_file_url ,
167137 timeout = 10 ,
168- duration = self .duration ,
169138 caption = self .caption )
170139
171140 video = message .video
@@ -175,7 +144,7 @@ def test_send_video_mp4_file_url(self):
175144 self .assertEqual (video .height , self .height )
176145 self .assertEqual (video .duration , self .duration )
177146 self .assertEqual (video .thumb , self .thumb_from_url )
178- self .assertEqual (video .mime_type , 'video/mp4' )
147+ self .assertEqual (video .mime_type , self . mime_type )
179148 self .assertEqual (video .file_size , self .file_size )
180149
181150 self .assertEqual (message .caption , self .caption )
@@ -193,9 +162,9 @@ def test_send_video_resend(self):
193162 video = message .video
194163
195164 self .assertEqual (video .file_id , self .video_file_id )
196- self .assertEqual (video .duration , 5 )
197- self .assertEqual (video .thumb , None )
198- self .assertEqual (video .mime_type , 'video/mp4' )
165+ self .assertEqual (video .duration , self . duration )
166+ self .assertEqual (video .thumb , self . thumb )
167+ self .assertEqual (video .mime_type , self . mime_type )
199168
200169 self .assertEqual (message .caption , self .caption )
201170
@@ -234,10 +203,8 @@ def test_error_send_video_empty_file(self):
234203 del (json_dict ['file_id' ])
235204 json_dict ['video' ] = open (os .devnull , 'rb' )
236205
237- self .assertRaises (telegram .TelegramError ,
238- lambda : self ._bot .sendVideo (chat_id = self ._chat_id ,
239- timeout = 10 ,
240- ** json_dict ))
206+ with self .assertRaises (telegram .TelegramError ):
207+ self ._bot .sendVideo (chat_id = self ._chat_id , timeout = 10 , ** json_dict )
241208
242209 @flaky (3 , 1 )
243210 @timeout (10 )
@@ -247,23 +214,14 @@ def test_error_send_video_empty_file_id(self):
247214 del (json_dict ['file_id' ])
248215 json_dict ['video' ] = ''
249216
250- self .assertRaises (telegram .TelegramError ,
251- lambda : self ._bot .sendVideo (chat_id = self ._chat_id ,
252- timeout = 10 ,
253- ** json_dict ))
217+ with self .assertRaises (telegram .TelegramError ):
218+ self ._bot .sendVideo (chat_id = self ._chat_id ,timeout = 10 ,** json_dict )
254219
255220 @flaky (3 , 1 )
256221 @timeout (10 )
257222 def test_error_video_without_required_args (self ):
258- json_dict = self .json_dict
259-
260- del (json_dict ['file_id' ])
261- del (json_dict ['duration' ])
262-
263- self .assertRaises (TypeError ,
264- lambda : self ._bot .sendVideo (chat_id = self ._chat_id ,
265- timeout = 10 ,
266- ** json_dict ))
223+ # Obsolete: only required args are chat_id and video. Both tested above
224+ self .assertEqual (True , True )
267225
268226 @flaky (3 , 1 )
269227 @timeout (10 )
0 commit comments