diff options
author | 2024-07-13 15:55:17 +0530 | |
---|---|---|
committer | 2024-07-13 15:55:17 +0530 | |
commit | 43a8a2d07aeb8917d8a5aebab6a1851e9d827265 (patch) | |
tree | 33e9f60839c95a3ca8aa2b1589447690ffd30657 /tests/helpers.py | |
parent | "Jump to message" changed and added handling for Reference deleted messages (diff) | |
parent | Merge pull request #3074 from python-discord/faster-silence-tests (diff) |
Merge branch 'main' into main
Diffstat (limited to 'tests/helpers.py')
-rw-r--r-- | tests/helpers.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/helpers.py b/tests/helpers.py index c51a82a9d..1164828d6 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -388,12 +388,17 @@ class MockTextChannel(CustomMockMixin, unittest.mock.Mock, HashableMixin): spec_set = text_channel_instance def __init__(self, **kwargs) -> None: - default_kwargs = {"id": next(self.discord_id), "name": "channel", "guild": MockGuild()} + default_kwargs = {"id": next(self.discord_id), "name": "channel"} super().__init__(**collections.ChainMap(kwargs, default_kwargs)) if "mention" not in kwargs: self.mention = f"#{self.name}" + @cached_property + def guild(self) -> MockGuild: + """Cached guild property.""" + return MockGuild() + class MockVoiceChannel(CustomMockMixin, unittest.mock.Mock, HashableMixin): """ @@ -405,12 +410,17 @@ class MockVoiceChannel(CustomMockMixin, unittest.mock.Mock, HashableMixin): spec_set = voice_channel_instance def __init__(self, **kwargs) -> None: - default_kwargs = {"id": next(self.discord_id), "name": "channel", "guild": MockGuild()} + default_kwargs = {"id": next(self.discord_id), "name": "channel"} super().__init__(**collections.ChainMap(kwargs, default_kwargs)) if "mention" not in kwargs: self.mention = f"#{self.name}" + @cached_property + def guild(self) -> MockGuild: + """Cached guild property.""" + return MockGuild() + # Create data for the DMChannel instance state = unittest.mock.MagicMock() |