@@ -133,6 +133,10 @@ def asyncHandlerTest(self, bot, update):
133133 self .received_message = update .message .text
134134 self .message_count += 1
135135
136+ @run_async
137+ def asyncHandlerErrorTest (self , bot , update ):
138+ raise TelegramError ('foobar' )
139+
136140 def stringHandlerTest (self , bot , update ):
137141 self .received_message = update
138142 self .message_count += 1
@@ -170,8 +174,9 @@ def errorRaisingHandlerTest(self, bot, update):
170174 raise TelegramError (update )
171175
172176 def errorHandlerTest (self , bot , update , error ):
173- self .received_message = error .message
174- self .message_count += 1
177+ with self .lock :
178+ self .received_message = error .message
179+ self .message_count += 1
175180
176181 def test_addRemoveTelegramMessageHandler (self ):
177182 self ._setup_updater ('Test' )
@@ -573,6 +578,17 @@ def test_runAsync(self):
573578 self .assertEqual (self .received_message , 'Test5' )
574579 self .assertEqual (self .message_count , 2 )
575580
581+ def test_runAsyncError (self ):
582+ self ._setup_updater ('Test32' , messages = 1 )
583+ d = self .updater .dispatcher
584+ handler = MessageHandler ([], self .asyncHandlerErrorTest )
585+ d .add_handler (handler )
586+ d .add_error_handler (self .errorHandlerTest )
587+ self .updater .start_polling (0.01 )
588+ sleep (.2 )
589+ self .assertEqual (self .received_message , 'foobar' )
590+ self .assertEqual (self .message_count , 1 )
591+
576592 def test_multiple_dispatchers (self ):
577593
578594 def get_dispatcher_name (q ):
0 commit comments