aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-03-13 17:42:24 -0700
committerGravatar MarkKoz <[email protected]>2020-03-13 17:45:54 -0700
commit4d4975544ffec249aa6cd43d14987c00794caf99 (patch)
tree874baa8373f7b8e86b62c701d23169f2bf57bee7
parentCog tests: fix leading space in aliases without parents (diff)
Cog tests: fix error on import due to discord.ext.tasks.loop
The tasks extensions loop requires an event loop to exist. To work around this, it's been mocked.
-rw-r--r--tests/bot/cogs/test_cogs.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/tests/bot/cogs/test_cogs.py b/tests/bot/cogs/test_cogs.py
index cbd203786..db559ded6 100644
--- a/tests/bot/cogs/test_cogs.py
+++ b/tests/bot/cogs/test_cogs.py
@@ -6,6 +6,7 @@ import typing as t
import unittest
from collections import defaultdict
from types import ModuleType
+from unittest import mock
from discord.ext import commands
@@ -31,9 +32,10 @@ class CommandNameTests(unittest.TestCase):
def on_error(name: str) -> t.NoReturn:
raise ImportError(name=name)
- for module in pkgutil.walk_packages(cogs.__path__, "bot.cogs.", onerror=on_error):
- if not module.ispkg:
- yield importlib.import_module(module.name)
+ with mock.patch("discord.ext.tasks.loop"):
+ for module in pkgutil.walk_packages(cogs.__path__, "bot.cogs.", onerror=on_error):
+ if not module.ispkg:
+ yield importlib.import_module(module.name)
@staticmethod
def walk_cogs(module: ModuleType) -> t.Iterator[commands.Cog]: