Skip to content

Commit

Permalink
Fix test errors in plugin manager
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxdaemon committed Mar 15, 2024
1 parent 97ca8d0 commit bd42e49
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 3 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime
import importlib
import logging
from typing import List
from unittest.mock import MagicMock, patch
Expand Down Expand Up @@ -30,13 +31,13 @@ def caplog_bot(caplog):

@pytest.fixture()
def patch_import_module():
with patch("importlib.import_module") as mocked:
with patch.object(importlib, "import_module") as mocked:
yield mocked


@pytest.fixture()
def patch_import_reload():
with patch("importlib.reload") as mocked:
with patch.object(importlib, "reload") as mocked:
yield mocked


Expand Down
5 changes: 2 additions & 3 deletions tests/core_tests/test_plugin_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from cloudbot.util import database
from tests.util.mock_module import MockModule


@pytest.fixture()
def mock_bot(mock_bot_factory, event_loop, tmp_path):
tmp_base = tmp_path / "tmp"
Expand Down Expand Up @@ -138,8 +137,6 @@ def test_can_load(mock_manager):


def test_plugin_load(mock_manager, patch_import_module, patch_import_reload):
patch_import_module.reset_mock()
patch_import_reload.reset_mock()
patch_import_module.return_value = mod = MockModule()
mock_manager.bot.loop.run_until_complete(
mock_manager.load_plugin(mock_manager.bot.plugin_dir / "test.py")
Expand Down Expand Up @@ -223,6 +220,8 @@ def test_plugin_with_objs_full_dict_attr(mock_manager, patch_import_module):
def test_plugin_load_disabled(
mock_manager, patch_import_module, patch_import_reload
):
patch_import_module.reset_mock()
patch_import_reload.reset_mock()
patch_import_module.return_value = MockModule()
mock_manager.bot.config.update(
{
Expand Down

0 comments on commit bd42e49

Please sign in to comment.