Skip to content

The agent that grows with you

fix(tests): add _FakeAudioSource to discord mock for VoiceMixer inheritance

Carlos Diosdadod22a1ee5bec8
diff --git a/tests/gateway/conftest.py b/tests/gateway/conftest.py
index 978d634331a..9cbc99fdd53 100644
--- a/tests/gateway/conftest.py
+++ b/tests/gateway/conftest.py
@@ -184,6 +184,18 @@ def _ensure_discord_mock() -> None:
self.description = description
discord_mod.SelectOption = _FakeSelectOption
+ # AudioSource: real class so VoiceMixer(discord.AudioSource) can subclass
+ # it cleanly in tests. MagicMock auto-attributes would make is_opus()
+ # return a Mock instead of False, breaking 9 TestVoiceMixerCore tests.
+ class _FakeAudioSource:
+ def is_opus(self):
+ return False
+ def read(self):
+ return b"\x00" * 3840 # one silent stereo s16 frame
+ def cleanup(self):
+ pass
+ discord_mod.AudioSource = _FakeAudioSource
+
discord_mod.ui = SimpleNamespace(
View=_FakeView,
Select=_FakeSelect,