diff options
author | 2024-07-08 23:08:13 +0200 | |
---|---|---|
committer | 2024-07-08 23:08:13 +0200 | |
commit | e3d13808ee8a97b6d582d774910118a953fd25f5 (patch) | |
tree | 5a4f2e6db542b8284ae565ff0bf376e964053540 /tests/helpers.py | |
parent | Bump pytest-subtests from 0.12.1 to 0.13.0 (#3114) (diff) | |
parent | Merge branch 'main' into faster-silence-tests (diff) |
Merge pull request #3074 from python-discord/faster-silence-tests
Faster and Improved silence tests
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() |