From 03519e2a1604c3d904834e51fded14aa84763f1d Mon Sep 17 00:00:00 2001 From: Twirre Meulenbelt <43213592+TwirreM@users.noreply.github.com> Date: Fri, 14 Nov 2025 13:08:31 +0100 Subject: [PATCH] test: fix microphone interactive test This was created with the assumption that all devices were choosable, but now only ones with input channels are. ref: N25B-119 --- test/common/microphone_utils.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/common/microphone_utils.py b/test/common/microphone_utils.py index c82de37..74bd777 100644 --- a/test/common/microphone_utils.py +++ b/test/common/microphone_utils.py @@ -41,6 +41,9 @@ class MicrophoneUtils(object): """ First mock an input that's not an integer, then a valid integer. There should be no errors. """ + microphones = get_microphones(pyaudio_instance) + target_microphone = next(microphones) + mock_input = mocker.patch("__builtin__.raw_input", side_effect=["not an integer", "0"]) fake_out = StringIO() mocker.patch.object(sys, "stdout", fake_out) @@ -48,7 +51,7 @@ class MicrophoneUtils(object): result = choose_mic_interactive(pyaudio_instance) assert "index" in result assert isinstance(result["index"], (int, long)) - assert result["index"] == 0 + assert result["index"] == target_microphone["index"] assert mock_input.called @@ -58,6 +61,9 @@ class MicrophoneUtils(object): """ Make sure that the interactive method does not allow negative integers as input. """ + microphones = get_microphones(pyaudio_instance) + target_microphone = next(microphones) + mock_input = mocker.patch("__builtin__.raw_input", side_effect=["-1", "0"]) fake_out = StringIO() mocker.patch.object(sys, "stdout", fake_out) @@ -65,7 +71,7 @@ class MicrophoneUtils(object): result = choose_mic_interactive(pyaudio_instance) assert "index" in result assert isinstance(result["index"], (int, long)) - assert result["index"] == 0 + assert result["index"] == target_microphone["index"] assert mock_input.called