aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-03-09 13:37:56 -0700
committerGravatar MarkKoz <[email protected]>2020-03-13 17:11:05 -0700
commitb923c0f844f65275d90e3807aa8e3eadf3920252 (patch)
treebbebb1d1cb58c425f21173948eacc643f7e66a18 /tests
parentCog tests: add a function to get all extensions (diff)
Cog tests: add a function to get all cogs
Diffstat (limited to 'tests')
-rw-r--r--tests/bot/cogs/test_cogs.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/bot/cogs/test_cogs.py b/tests/bot/cogs/test_cogs.py
index 386299fb1..4290c279c 100644
--- a/tests/bot/cogs/test_cogs.py
+++ b/tests/bot/cogs/test_cogs.py
@@ -28,3 +28,10 @@ class CommandNameTests(unittest.TestCase):
"""Yield imported extensions (modules) from the bot.cogs subpackage."""
for module in pkgutil.iter_modules(cogs.__path__, "bot.cogs."):
yield importlib.import_module(module.name)
+
+ @staticmethod
+ def walk_cogs(extension: ModuleType) -> t.Iterator[commands.Cog]:
+ """Yield all cogs defined in an extension."""
+ for name, cls in extension.__dict__.items():
+ if isinstance(cls, commands.Cog):
+ yield getattr(extension, name)