Skip to content

Commit 7154371

Browse files
committed
Catch unit test exceptions on device without MIDI support
1 parent 1c5f91c commit 7154371

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

tests/test_timeline.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ def test_timeline_tempo():
1212
assert timeline.clock_source.tempo == pytest.approx(100)
1313

1414
def test_timeline_default_output_device():
15-
timeline = iso.Timeline()
1615
try:
16+
timeline = iso.Timeline()
1717
track = timeline.schedule({ "note": 0 })
1818
assert issubclass(type(track.output_device), MidiOutputDevice)
1919
except iso.DeviceNotFoundException:
@@ -271,18 +271,26 @@ def callback():
271271
assert dummy_timeline.done
272272

273273
def test_timeline_beats_to_seconds(dummy_timeline):
274-
timeline = iso.Timeline(120)
275-
assert timeline.beats_to_seconds(1) == pytest.approx(0.5)
276-
assert timeline.beats_to_seconds(0) == pytest.approx(0.0)
277-
timeline.tempo = 180
278-
assert timeline.beats_to_seconds(1) == pytest.approx(1/3)
274+
try:
275+
timeline = iso.Timeline(120)
276+
assert timeline.beats_to_seconds(1) == pytest.approx(0.5)
277+
assert timeline.beats_to_seconds(0) == pytest.approx(0.0)
278+
timeline.tempo = 180
279+
assert timeline.beats_to_seconds(1) == pytest.approx(1/3)
280+
except iso.DeviceNotFoundException:
281+
# Ignore exception on machines without a MIDI device
282+
pass
279283

280284
def test_timeline_seconds_to_beats(dummy_timeline):
281-
timeline = iso.Timeline(120)
282-
assert timeline.seconds_to_beats(1) == pytest.approx(2)
283-
assert timeline.seconds_to_beats(0) == pytest.approx(0.0)
284-
timeline.tempo = 180
285-
assert timeline.seconds_to_beats(1) == pytest.approx(3)
285+
try:
286+
timeline = iso.Timeline(120)
287+
assert timeline.seconds_to_beats(1) == pytest.approx(2)
288+
assert timeline.seconds_to_beats(0) == pytest.approx(0.0)
289+
timeline.tempo = 180
290+
assert timeline.seconds_to_beats(1) == pytest.approx(3)
291+
except iso.DeviceNotFoundException:
292+
# Ignore exception on machines without a MIDI device
293+
pass
286294

287295
def test_timeline_tempo(dummy_timeline):
288296
# Set tempo of internal clock

0 commit comments

Comments
 (0)