From e1f3f346bc654cc12ca77f74b6e184ec42770e32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannes=20H=C3=B6ke?= Date: Tue, 24 Nov 2015 14:57:54 +0100 Subject: [PATCH] Test for Update.idle() --- tests/test_boteventhandler.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_boteventhandler.py b/tests/test_boteventhandler.py index 39f2d7433..39945fdc5 100644 --- a/tests/test_boteventhandler.py +++ b/tests/test_boteventhandler.py @@ -22,6 +22,8 @@ import logging import unittest import sys import re +import os +import signal from random import randrange from time import sleep from datetime import datetime @@ -259,6 +261,21 @@ class BotEventHandlerTest(BaseTest, unittest.TestCase): sleep(1) self.assertEqual(self.received_message, 'Webhook Test') + def signalsender(self): + sleep(0.5) + os.kill(os.getpid(), signal.SIGTERM) + + def test_idle(self): + print('Testing idle') + self.updater.bot = MockBot('Test4', messages=0) + self.updater.start_polling(poll_interval=0.01) + Thread(target=self.signalsender).start() + self.updater.idle() + # If we get this far, idle() ran through + sleep(1) + self.updater.running = False + + class MockBot: