mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-03-17 04:39:55 +01:00
make sure to stop conpool between sensitive unitests
This commit is contained in:
parent
d37b6d6735
commit
a814e9de6b
3 changed files with 14 additions and 0 deletions
|
@ -49,10 +49,19 @@ def _get_con_pool():
|
|||
])
|
||||
return _CON_POOL
|
||||
|
||||
|
||||
def is_con_pool_initialized():
|
||||
return _CON_POOL is not None
|
||||
|
||||
|
||||
def stop_con_pool():
|
||||
global _CON_POOL
|
||||
if _CON_POOL is not None:
|
||||
_CON_POOL.close()
|
||||
_CON_POOL = None
|
||||
|
||||
|
||||
|
||||
def _parse(json_data):
|
||||
"""Try and parse the JSON returned from Telegram.
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
#
|
||||
|
@ -31,6 +32,7 @@ else:
|
|||
|
||||
sys.path.append('.')
|
||||
|
||||
from telegram.utils.request import stop_con_pool
|
||||
from telegram.ext import JobQueue, Updater
|
||||
from tests.base import BaseTest
|
||||
|
||||
|
@ -58,6 +60,7 @@ class JobQueueTest(BaseTest, unittest.TestCase):
|
|||
def tearDown(self):
|
||||
if self.jq is not None:
|
||||
self.jq.stop()
|
||||
stop_con_pool()
|
||||
|
||||
def job1(self, bot):
|
||||
self.result += 1
|
||||
|
|
|
@ -48,6 +48,7 @@ except ImportError:
|
|||
sys.path.append('.')
|
||||
|
||||
from telegram import Update, Message, TelegramError, User, Chat, Bot
|
||||
from telegram.utils.request import stop_con_pool
|
||||
from telegram.ext import *
|
||||
from telegram.ext.dispatcher import run_async
|
||||
from telegram.error import Unauthorized, InvalidToken
|
||||
|
@ -84,6 +85,7 @@ class UpdaterTest(BaseTest, unittest.TestCase):
|
|||
def tearDown(self):
|
||||
if self.updater is not None:
|
||||
self.updater.stop()
|
||||
stop_con_pool()
|
||||
|
||||
def reset(self):
|
||||
self.message_count = 0
|
||||
|
|
Loading…
Add table
Reference in a new issue