Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
)
Comment on lines +23 to +27
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] A requires_portaudio marker is defined here but is never used. The test modules use module-level pytest.skip() instead. This creates two different mechanisms for the same purpose, which could lead to confusion.

Consider either:

  1. Removing this unused marker if module-level skips are the preferred approach, or
  2. Using this marker with @requires_portaudio decorators on test functions/classes instead of module-level skips

The current implementation works correctly, but having both mechanisms reduces code clarity.

Suggested change
# 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)"
)

Copilot uses AI. Check for mistakes.


@pytest.fixture(autouse=True)
def reset_config():
"""Reset configuration to default values before each test."""
Expand Down Expand Up @@ -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')

Expand Down
7 changes: 7 additions & 0 deletions tests/test_arpeggiator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
"""Tests for arpeggiator functionality."""

import pytest

# Skip entire module if sounddevice/PortAudio is not available
try:
import sounddevice
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'sounddevice' is not used.

Copilot uses AI. Check for mistakes.
except OSError:
pytest.skip("PortAudio library not found", allow_module_level=True)

from unittest.mock import patch
from PyQt5.QtWidgets import QApplication

Expand Down
8 changes: 8 additions & 0 deletions tests/test_controller.py
Original file line number Diff line number Diff line change
@@ -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
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'sounddevice' is not used.

Copilot uses AI. Check for mistakes.
except OSError:
pytest.skip("PortAudio library not found", allow_module_level=True)

import time
from unittest.mock import patch, MagicMock
import threading
Expand Down
10 changes: 8 additions & 2 deletions tests/test_input.py
Original file line number Diff line number Diff line change
@@ -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
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'sounddevice' is not used.

Copilot uses AI. Check for mistakes.
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

Expand Down
9 changes: 8 additions & 1 deletion tests/test_keyboard_integration.py
Original file line number Diff line number Diff line change
@@ -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
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'sounddevice' is not used.

Copilot uses AI. Check for mistakes.
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
Expand Down
9 changes: 8 additions & 1 deletion tests/test_midi_integration.py
Original file line number Diff line number Diff line change
@@ -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
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'sounddevice' is not used.

Copilot uses AI. Check for mistakes.
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

Expand Down
8 changes: 8 additions & 0 deletions tests/test_synth.py
Original file line number Diff line number Diff line change
@@ -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
Copy link

Copilot AI Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import of 'sounddevice' is not used.

Copilot uses AI. Check for mistakes.
except OSError:
pytest.skip("PortAudio library not found", allow_module_level=True)

import numpy as np
from unittest.mock import patch, Mock
import threading
Expand Down
Loading