Skip to content

Commit bd42e49

Browse files
committed
Fix test errors in plugin manager
1 parent 97ca8d0 commit bd42e49

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

tests/conftest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import datetime
2+
import importlib
23
import logging
34
from typing import List
45
from unittest.mock import MagicMock, patch
@@ -30,13 +31,13 @@ def caplog_bot(caplog):
3031

3132
@pytest.fixture()
3233
def patch_import_module():
33-
with patch("importlib.import_module") as mocked:
34+
with patch.object(importlib, "import_module") as mocked:
3435
yield mocked
3536

3637

3738
@pytest.fixture()
3839
def patch_import_reload():
39-
with patch("importlib.reload") as mocked:
40+
with patch.object(importlib, "reload") as mocked:
4041
yield mocked
4142

4243

tests/core_tests/test_plugin_manager.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from cloudbot.util import database
1515
from tests.util.mock_module import MockModule
1616

17-
1817
@pytest.fixture()
1918
def mock_bot(mock_bot_factory, event_loop, tmp_path):
2019
tmp_base = tmp_path / "tmp"
@@ -138,8 +137,6 @@ def test_can_load(mock_manager):
138137

139138

140139
def test_plugin_load(mock_manager, patch_import_module, patch_import_reload):
141-
patch_import_module.reset_mock()
142-
patch_import_reload.reset_mock()
143140
patch_import_module.return_value = mod = MockModule()
144141
mock_manager.bot.loop.run_until_complete(
145142
mock_manager.load_plugin(mock_manager.bot.plugin_dir / "test.py")
@@ -223,6 +220,8 @@ def test_plugin_with_objs_full_dict_attr(mock_manager, patch_import_module):
223220
def test_plugin_load_disabled(
224221
mock_manager, patch_import_module, patch_import_reload
225222
):
223+
patch_import_module.reset_mock()
224+
patch_import_reload.reset_mock()
226225
patch_import_module.return_value = MockModule()
227226
mock_manager.bot.config.update(
228227
{

0 commit comments

Comments
 (0)