From 183bb933b43c8de0cbda41d63194cc01df69ee36 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 25 Oct 2023 14:59:31 -0700 Subject: [PATCH] test_run: Patch importlib.import_module last. importlib.import_module is now used in the implementation of unittest.mock.patch. Signed-off-by: Anders Kaseorg --- zulip_bots/zulip_bots/tests/test_run.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/zulip_bots/zulip_bots/tests/test_run.py b/zulip_bots/zulip_bots/tests/test_run.py index c2c6983f..966530fd 100644 --- a/zulip_bots/zulip_bots/tests/test_run.py +++ b/zulip_bots/zulip_bots/tests/test_run.py @@ -120,11 +120,11 @@ class TestDefaultArguments(TestCase): with patch( "sys.argv", ["zulip-run-bot", "bot.module.name", "--config-file", "/path/to/config"] ): - with patch( - "importlib.import_module", return_value=mock_bot_module - ) as mock_import_module: - with patch("zulip_bots.run.run_message_handler_for_bot"): - with patch("zulip_bots.run.exit_gracefully_if_zulip_config_is_missing"): + with patch("zulip_bots.run.run_message_handler_for_bot"): + with patch("zulip_bots.run.exit_gracefully_if_zulip_config_is_missing"): + with patch( + "importlib.import_module", return_value=mock_bot_module + ) as mock_import_module: zulip_bots.run.main() mock_import_module.assert_called_once_with(bot_module_name)