Skip to content

Commit

Permalink
test_fader: use pytest.mark.parametrize (yield tests are deprecated)
Browse files Browse the repository at this point in the history
  • Loading branch information
virtuald committed Apr 24, 2017
1 parent 44c9b33 commit 0b7fa62
Showing 1 changed file with 22 additions and 27 deletions.
49 changes: 22 additions & 27 deletions tests/xl/player/gst/test_fader.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

from gi.repository import GLib
import pytest

from xl.player.track_fader import TrackFader, FadeState

Expand Down Expand Up @@ -64,39 +65,34 @@ def glib_source_remove(src_id):
TmEx = 2


def test_fader():

#
# TODO: These tests don't cover setup_track, et al
#
# Test data:
# Position, Volume, State, TmSt/TmEx/None, [call, [arg1...]]

# Test data:
# Position, Volume, State, TmSt/TmEx/None, [call, [arg1...]]

tests = []
@pytest.mark.parametrize('test', [
# Test don't manage the volume
tests.append([
[
(0, 100, NoFade, None, 'play', None, None, None, None),
(1, 100, NoFade, None, 'pause'),
(2, 100, NoFade, None, 'unpause'),
(3, 100, NoFade, None, 'seek', 4),
(4, 100, NoFade, None, 'stop'),
(5, 100, NoFade, None),
])
],
# Test fading in
tests.append([
[
(0, 0, FadingIn, TmEx, 'play', 0, 2, None, None),
(1, 50, FadingIn, TmEx, 'execute'),
(3, 100, NoFade, None, 'execute'),
(4, 100, NoFade, None),
(5, 100, NoFade, None, 'stop'),
(6, 100, NoFade, None),
])
],
# Test fading in: pause in middle
tests.append([
[
(0, 0, FadingIn, TmEx, 'play', 0, 2, None, None),
(1, 50, FadingIn, TmEx, 'execute'),
(1, 50, FadingIn, None, 'pause'),
Expand All @@ -106,28 +102,28 @@ def test_fader():
(4, 100, NoFade, None),
(5, 100, NoFade, None, 'stop'),
(6, 100, NoFade, None),
])
],
# Test fading in past the fade point
tests.append([
[
(3, 100, NoFade, None, 'play', 0, 2, None, None),
(4, 100, NoFade, None),
(5, 100, NoFade, None, 'stop'),
(6, 100, NoFade, None),
])
],
# Test fading out
tests.append([
[
(3, 100, Normal, TmSt, 'play', None, None, 4, 6),
(4, 100, FadingOut, TmEx, 'start'),
(5, 50, FadingOut, TmEx, 'execute'),
(6, 0, FadingOut, TmEx, 'execute'),
(6.1, 0, NoFade, None, 'execute'),
(7, 0, NoFade, None),
])
],
# Test all of them
tests.append([
[
(0, 0, FadingIn, TmEx, 'play', 0, 2, 4, 6),
(1, 50, FadingIn, TmEx, 'execute'),
(3, 100, Normal, TmSt, 'execute'),
Expand All @@ -136,14 +132,16 @@ def test_fader():
(6, 0, FadingOut, TmEx, 'execute'),
(6.1, 0, NoFade, None, 'execute'),
(7, 0, NoFade, None),
])
],
# Test fading in with startoffset
# tests.append([
# [
# (0, 0, FadingIn, TmEx, 'play', 60, 62, 64, 66),
# (0, 0, FadingIn, TmEx, 'seek', 60),
# (61, 50, FadingIn, TmEx, 'execute'),
# ])
# ],
])
def test_fader(test):

# Test fade_out_on_play

Expand All @@ -152,13 +150,10 @@ def test_fader():
# Test setup_track is_update=True

# Test unexpected fading out

for test in tests:
yield check_fader, test


check_fader(test)

def check_fader(test):

stream = FakeStream()
fader = TrackFader(stream, stream.on_fade_out, 'test')

Expand Down

0 comments on commit 0b7fa62

Please sign in to comment.