aboutsummaryrefslogtreecommitdiffstats
path: root/tests/helpers.py
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2023-06-14 15:57:44 +0100
committerGravatar Chris Lovering <[email protected]>2023-06-21 20:42:42 +0100
commitc868811621da78feaa370d67d49ce4661e9cc359 (patch)
treeb6459b539f05a362b8766b28134b0daecbc5cbaf /tests/helpers.py
parentBump pydis-core from 9.7.0 to 9.8.0 (diff)
Write custom get_role func for MockMember
The new d.py Member.get_role uses the Guild.get_role function if the member has the role. SInce we don't set Guild.roles overwrite this instead.
Diffstat (limited to 'tests/helpers.py')
-rw-r--r--tests/helpers.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/tests/helpers.py b/tests/helpers.py
index b5a3f2463..b7e5cc871 100644
--- a/tests/helpers.py
+++ b/tests/helpers.py
@@ -256,6 +256,9 @@ class MockMember(CustomMockMixin, unittest.mock.Mock, ColourMixin, HashableMixin
if "mention" not in kwargs:
self.mention = f"@{self.name}"
+ def get_role(self, role_id: int) -> MockRole | None:
+ return discord.utils.get(self.roles, id=role_id)
+
# Create a User instance to get a realistic Mock of `discord.User`
_user_data_mock = collections.defaultdict(unittest.mock.MagicMock, {