Skip to content

Commit e118dc5

Browse files
rebased and fixed the tests
1 parent 34d5eb3 commit e118dc5

1 file changed

Lines changed: 21 additions & 13 deletions

File tree

tests/rtc/test_platform_audio.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -158,19 +158,27 @@ def test_set_playout_device_valid(self, platform_audio):
158158
# Should not raise
159159
platform_audio.set_playout_device(devices[0].id)
160160

161-
def test_set_recording_device_invalid(self, platform_audio):
162-
"""Test that setting an invalid recording device raises an error."""
163-
with pytest.raises(rtc.PlatformAudioError) as exc_info:
164-
platform_audio.set_recording_device("invalid-device-id-that-does-not-exist")
165-
166-
assert "not found" in str(exc_info.value).lower() or "failed" in str(exc_info.value).lower()
167-
168-
def test_set_playout_device_invalid(self, platform_audio):
169-
"""Test that setting an invalid playout device raises an error."""
170-
with pytest.raises(rtc.PlatformAudioError) as exc_info:
171-
platform_audio.set_playout_device("invalid-device-id-that-does-not-exist")
172-
173-
assert "not found" in str(exc_info.value).lower() or "failed" in str(exc_info.value).lower()
161+
def test_set_recording_device_invalid_falls_back_to_default(self, platform_audio):
162+
"""Test that setting an invalid recording device falls back to default (no error).
163+
164+
When a device GUID is invalid (e.g., device was unplugged), the system
165+
gracefully falls back to the default device instead of raising an error.
166+
This is intentional behavior for better UX - a saved device preference
167+
shouldn't crash the app if the device is removed.
168+
"""
169+
# Should not raise - falls back to default device
170+
platform_audio.set_recording_device("invalid-device-id-that-does-not-exist")
171+
172+
def test_set_playout_device_invalid_falls_back_to_default(self, platform_audio):
173+
"""Test that setting an invalid playout device falls back to default (no error).
174+
175+
When a device GUID is invalid (e.g., device was unplugged), the system
176+
gracefully falls back to the default device instead of raising an error.
177+
This is intentional behavior for better UX - a saved device preference
178+
shouldn't crash the app if the device is removed.
179+
"""
180+
# Should not raise - falls back to default device
181+
platform_audio.set_playout_device("invalid-device-id-that-does-not-exist")
174182

175183

176184
class TestAudioSourceCreation:

0 commit comments

Comments
 (0)