From 9bf64c0c21275e5f29318e194ddf66c5087f5514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20H=C3=B6nig?= Date: Sat, 30 Dec 2017 21:45:20 +0100 Subject: [PATCH] youtube bot: Replace sys.exit() with bot_handler.quit(). --- zulip_bots/zulip_bots/bots/youtube/test_youtube.py | 2 +- zulip_bots/zulip_bots/bots/youtube/youtube.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/zulip_bots/zulip_bots/bots/youtube/test_youtube.py b/zulip_bots/zulip_bots/bots/youtube/test_youtube.py index 961c1c9..6273d4b 100644 --- a/zulip_bots/zulip_bots/bots/youtube/test_youtube.py +++ b/zulip_bots/zulip_bots/bots/youtube/test_youtube.py @@ -39,7 +39,7 @@ class TestYoutubeBot(BotTestCase): with self.mock_config_info({'key': 'somethinginvalid', 'number_of_results': '5', 'video_region': 'US'}), \ self.mock_http_conversation('test_invalid_key'), \ - self.assertRaises(SystemExit) as se: # type: ignore + self.assertRaises(bot_handler.BotQuitException): bot.initialize(bot_handler) def test_multiple(self) -> None: diff --git a/zulip_bots/zulip_bots/bots/youtube/youtube.py b/zulip_bots/zulip_bots/bots/youtube/youtube.py index 6404163..200ca7a 100644 --- a/zulip_bots/zulip_bots/bots/youtube/youtube.py +++ b/zulip_bots/zulip_bots/bots/youtube/youtube.py @@ -31,9 +31,8 @@ class YoutubeHandler(object): search_youtube('test', self.config_info['key'], self.config_info['video_region']) except HTTPError as e: if (e.response.json()['error']['errors'][0]['reason'] == 'keyInvalid'): - logging.error('Invalid key.' - 'Follow the instructions in doc.md for setting API key.') - sys.exit(1) + bot_handler.quit('Invalid key.' + 'Follow the instructions in doc.md for setting API key.') else: raise except ConnectionError: