bot tests: import patch in incrementor & monkeytestit as in other tests.
This makes the code more compact and consistent.
MODIFY
zulip_bots/zulip_bots/bots/incrementor/test_incrementor.py
zulip_bots/zulip_bots/bots/incrementor/test_incrementor.py
-from unittest import mock
+from unittest.mock import patch
from zulip_bots.test_lib import (
get_bot_message_handler,
@@ -19,7 +19,7 @@ class TestIncrementorBot(BotTestCase, DefaultTests):
bot.initialize(bot_handler)
bot.handle_message(message, bot_handler)
- with mock.patch('zulip_bots.simple_lib.SimpleMessageServer.update') as m:
+ with patch('zulip_bots.simple_lib.SimpleMessageServer.update') as m:
bot.handle_message(message, bot_handler)
bot.handle_message(message, bot_handler)
bot.handle_message(message, bot_handler)

MODIFY
zulip_bots/zulip_bots/bots/monkeytestit/test_monkeytestit.py
zulip_bots/zulip_bots/bots/monkeytestit/test_monkeytestit.py
-from unittest import mock, skipIf
+from unittest.mock import patch
+from unittest import skipIf
from sys import version_info
@@ -18,7 +19,7 @@ class TestMonkeyTestitBot(BotTestCase, DefaultTests):
content='',
type='stream',
)
- with mock.patch.object(self.monkeytestit_class, 'initialize', return_value=None):
+ with patch.object(self.monkeytestit_class, 'initialize', return_value=None):
with self.mock_config_info({'api_key': "magic"}):
res = self.get_response(message)
self.assertTrue("Unknown command" in res['content'])
@@ -28,7 +29,7 @@ class TestMonkeyTestitBot(BotTestCase, DefaultTests):
content='check https://website.com',
type='stream',
)
- with mock.patch.object(self.monkeytestit_class, 'initialize', return_value=None):
+ with patch.object(self.monkeytestit_class, 'initialize', return_value=None):
with self.mock_config_info({'api_key': "magic"}):
with self.mock_http_conversation('website_result_fail'):
res = self.get_response(message)
@@ -39,7 +40,7 @@ class TestMonkeyTestitBot(BotTestCase, DefaultTests):
content='check https://website.com',
type='stream',
)
- with mock.patch.object(self.monkeytestit_class, 'initialize', return_value=None):
+ with patch.object(self.monkeytestit_class, 'initialize', return_value=None):
with self.mock_config_info({'api_key': "magic"}):
with self.mock_http_conversation('website_result_success'):
res = self.get_response(message)

bot tests: import patch in incrementor & monkeytestit as in other tests.

This makes the code more compact and consistent.