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