diff --git a/tests/conftest.py b/tests/conftest.py index 44f921f..047ebe2 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -11,6 +11,22 @@ from qwerty_synth import config +def is_portaudio_available(): + """Check if PortAudio library is available.""" + try: + import sounddevice + return True + except OSError: + return False + + +# Create a pytest marker for tests requiring PortAudio +requires_portaudio = pytest.mark.skipif( + not is_portaudio_available(), + reason="PortAudio library not found (install portaudio19-dev system package)" +) + + @pytest.fixture(autouse=True) def reset_config(): """Reset configuration to default values before each test.""" @@ -157,6 +173,8 @@ def noise(): @pytest.fixture def mock_oscillator(): """Create a mock oscillator for testing.""" + if not is_portaudio_available(): + pytest.skip("PortAudio library not found") from qwerty_synth.synth import Oscillator return Oscillator(440.0, 'sine') diff --git a/tests/test_arpeggiator.py b/tests/test_arpeggiator.py index 803362f..44d647d 100644 --- a/tests/test_arpeggiator.py +++ b/tests/test_arpeggiator.py @@ -1,6 +1,13 @@ """Tests for arpeggiator functionality.""" import pytest + +# Skip entire module if sounddevice/PortAudio is not available +try: + import sounddevice +except OSError: + pytest.skip("PortAudio library not found", allow_module_level=True) + from unittest.mock import patch from PyQt5.QtWidgets import QApplication diff --git a/tests/test_controller.py b/tests/test_controller.py index a964856..9b63b72 100644 --- a/tests/test_controller.py +++ b/tests/test_controller.py @@ -1,5 +1,13 @@ """Comprehensive unit tests for the controller functionality.""" +import pytest + +# Skip entire module if sounddevice/PortAudio is not available +try: + import sounddevice +except OSError: + pytest.skip("PortAudio library not found", allow_module_level=True) + import time from unittest.mock import patch, MagicMock import threading diff --git a/tests/test_input.py b/tests/test_input.py index 8da2fe3..0a6e927 100644 --- a/tests/test_input.py +++ b/tests/test_input.py @@ -1,10 +1,16 @@ """Integration tests covering keyboard events routed through the controller.""" +import pytest + +# Skip entire module if sounddevice/PortAudio is not available +try: + import sounddevice +except OSError: + pytest.skip("PortAudio library not found", allow_module_level=True) + from types import SimpleNamespace from unittest.mock import Mock, patch, call -import pytest - from qwerty_synth import config, controller from qwerty_synth.keyboard_midi import MidiEvent diff --git a/tests/test_keyboard_integration.py b/tests/test_keyboard_integration.py index 441fb42..7a984b9 100644 --- a/tests/test_keyboard_integration.py +++ b/tests/test_keyboard_integration.py @@ -1,8 +1,15 @@ """Integration tests covering keyboard translator to controller flows.""" +import pytest + +# Skip entire module if sounddevice/PortAudio is not available +try: + import sounddevice +except OSError: + pytest.skip("PortAudio library not found", allow_module_level=True) + from unittest.mock import Mock -import pytest from pynput.keyboard import Key, KeyCode from qwerty_synth import config, controller diff --git a/tests/test_midi_integration.py b/tests/test_midi_integration.py index 60b5089..2de8901 100644 --- a/tests/test_midi_integration.py +++ b/tests/test_midi_integration.py @@ -1,8 +1,15 @@ """Integration test for MIDI controller → controller flow.""" -from unittest.mock import Mock, MagicMock, patch import pytest +# Skip entire module if sounddevice/PortAudio is not available +try: + import sounddevice +except OSError: + pytest.skip("PortAudio library not found", allow_module_level=True) + +from unittest.mock import Mock, MagicMock, patch + from qwerty_synth import config, controller from qwerty_synth.midi_input import MidiPortTranslator diff --git a/tests/test_synth.py b/tests/test_synth.py index 6b4096a..dfff78b 100644 --- a/tests/test_synth.py +++ b/tests/test_synth.py @@ -1,5 +1,13 @@ """Comprehensive unit tests for the core synthesizer functionality.""" +import pytest + +# Skip entire module if sounddevice/PortAudio is not available +try: + import sounddevice +except OSError: + pytest.skip("PortAudio library not found", allow_module_level=True) + import numpy as np from unittest.mock import patch, Mock import threading