Skip to content

Commit

Permalink
Catch unit test exceptions on device without MIDI support
Browse files Browse the repository at this point in the history
  • Loading branch information
ideoforms committed Nov 10, 2024
1 parent 1c5f91c commit 7154371
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions tests/test_timeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def test_timeline_tempo():
assert timeline.clock_source.tempo == pytest.approx(100)

def test_timeline_default_output_device():
timeline = iso.Timeline()
try:
timeline = iso.Timeline()
track = timeline.schedule({ "note": 0 })
assert issubclass(type(track.output_device), MidiOutputDevice)
except iso.DeviceNotFoundException:
Expand Down Expand Up @@ -271,18 +271,26 @@ def callback():
assert dummy_timeline.done

def test_timeline_beats_to_seconds(dummy_timeline):
timeline = iso.Timeline(120)
assert timeline.beats_to_seconds(1) == pytest.approx(0.5)
assert timeline.beats_to_seconds(0) == pytest.approx(0.0)
timeline.tempo = 180
assert timeline.beats_to_seconds(1) == pytest.approx(1/3)
try:
timeline = iso.Timeline(120)
assert timeline.beats_to_seconds(1) == pytest.approx(0.5)
assert timeline.beats_to_seconds(0) == pytest.approx(0.0)
timeline.tempo = 180
assert timeline.beats_to_seconds(1) == pytest.approx(1/3)
except iso.DeviceNotFoundException:
# Ignore exception on machines without a MIDI device
pass

def test_timeline_seconds_to_beats(dummy_timeline):
timeline = iso.Timeline(120)
assert timeline.seconds_to_beats(1) == pytest.approx(2)
assert timeline.seconds_to_beats(0) == pytest.approx(0.0)
timeline.tempo = 180
assert timeline.seconds_to_beats(1) == pytest.approx(3)
try:
timeline = iso.Timeline(120)
assert timeline.seconds_to_beats(1) == pytest.approx(2)
assert timeline.seconds_to_beats(0) == pytest.approx(0.0)
timeline.tempo = 180
assert timeline.seconds_to_beats(1) == pytest.approx(3)
except iso.DeviceNotFoundException:
# Ignore exception on machines without a MIDI device
pass

def test_timeline_tempo(dummy_timeline):
# Set tempo of internal clock
Expand Down

0 comments on commit 7154371

Please sign in to comment.