From d57cdd27cb7ff3f2e535eca9f58db653bc7d47f0 Mon Sep 17 00:00:00 2001 From: Filip Musial Date: Tue, 18 Apr 2023 02:38:46 -0400 Subject: [PATCH] Added docstrings --- discord/ext/test/runner.py | 4 +++- discord/ext/test/state.py | 6 ++++++ discord/ext/test/voice.py | 9 +++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/discord/ext/test/runner.py b/discord/ext/test/runner.py index bb21281..0d2d7a0 100644 --- a/discord/ext/test/runner.py +++ b/discord/ext/test/runner.py @@ -147,7 +147,9 @@ async def _edit_member_callback(fields: typing.Any, member: discord.Member, reas Internal callback. Updates a guild's voice states to reflect the given Member connecting to the given channel. Other updates to members are handled in http.edit_member(). - :param fields: Fields passed in from Member.edit() + :param fields: Fields passed in from Member.edit(). + :param member: The Member to edit. + :param reason: The reason for editing. Not used. """ data = {'user_id': member.id} guild = member.guild diff --git a/discord/ext/test/state.py b/discord/ext/test/state.py index 76aba79..0bb4bb0 100644 --- a/discord/ext/test/state.py +++ b/discord/ext/test/state.py @@ -77,6 +77,12 @@ def _guild_needs_chunking(self, guild: discord.Guild): return False def parse_channel_create(self, data) -> None: + """ + Need to make sure that FakeVoiceChannels are created when this is called to create VoiceChannels. Otherwise, + guilds would not be set up correctly. + + :param data: info to use in channel creation. + """ if data['type'] == discord.ChannelType.voice.value: factory, ch_type = FakeVoiceChannel, discord.ChannelType.voice.value else: diff --git a/discord/ext/test/voice.py b/discord/ext/test/voice.py index 24821e2..b743156 100644 --- a/discord/ext/test/voice.py +++ b/discord/ext/test/voice.py @@ -6,12 +6,21 @@ class FakeVoiceClient(VoiceClient): + """ + Mock implementation of a Discord VoiceClient. VoiceClient.connect tries to contact the Discord API and is called + whenever connect() is called on a VoiceChannel, so we need to override that method and pass in the fake version + to prevent the program from actually making calls to the Discord API. + """ async def connect(self, *, reconnect: bool, timeout: float, self_deaf: bool = False, self_mute: bool = False) -> None: self._connected.set() class FakeVoiceChannel(VoiceChannel): + """ + Mock implementation of a Discord VoiceChannel. Exists just to pass a FakeVoiceClient into the superclass connect() + method. + """ async def connect( self,