Skip to content

Commit 996e398

Browse files
authored
Merge pull request #129 from DakaraProject/fix/ci_integration_windows
Fix failing integration tests for Windows
2 parents ecbb1e5 + f39e16c commit 996e398

File tree

3 files changed

+34
-14
lines changed

3 files changed

+34
-14
lines changed

.github/workflows/ci.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,6 @@ jobs:
5656
steps:
5757
- uses: actions/checkout@v4
5858

59-
- uses: actions/setup-python@v5
60-
with:
61-
python-version: "3.12"
62-
cache: "pip"
63-
6459
- name: Install native dependencies (Ubuntu)
6560
run: sudo apt-get update && sudo apt-get install -y vlc mpv
6661
if: matrix.os == 'ubuntu-latest'
@@ -92,6 +87,11 @@ jobs:
9287
- name: Print Mpv version
9388
run: mpv --version
9489

90+
- uses: actions/setup-python@v5
91+
with:
92+
python-version: "3.12"
93+
cache: "pip"
94+
9595
- name: Install python tests dependencies
9696
run: pip install -e ".[dev]"
9797

tests/integration/test_media_player_mpv.py

+15-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
from dakara_player.media_player.mpv import MediaPlayerMpv
1919
from tests.integration.base import TestCasePollerKara
2020

21-
REWIND_FAST_FORWARD_DURATION = 0.2
21+
REWIND_FAST_FORWARD_DURATION = 0.5
22+
REWIND_FAST_FORWARD_DELTA = 1
23+
DEFAULT_DELTA = 0.2
2224

2325

2426
@skipUnless(MediaPlayerMpv.is_available(), "mpv not installed")
@@ -427,7 +429,7 @@ def test_restart_song(self):
427429
mpv_player.restart()
428430

429431
# check timing is 0
430-
self.assertAlmostEqual(mpv_player.player.time_pos, 0, 0)
432+
self.assertAlmostEqual(mpv_player.player.time_pos, 0, delta=DEFAULT_DELTA)
431433

432434
# check the song is not stopped
433435
self.assertIsNotNone(mpv_player.playlist_entry)
@@ -768,7 +770,11 @@ def test_rewind_song(self):
768770
# check timing is earlier than previously
769771
timing2 = mpv_player.player.time_pos
770772
self.assertLess(timing2, timing1)
771-
self.assertAlmostEqual(timing1 - timing2, REWIND_FAST_FORWARD_DURATION, 1)
773+
self.assertAlmostEqual(
774+
timing1 - timing2,
775+
REWIND_FAST_FORWARD_DURATION,
776+
delta=REWIND_FAST_FORWARD_DELTA,
777+
)
772778

773779
# assert callback
774780
mpv_player.callbacks["updated_timing"].assert_called_with(
@@ -800,7 +806,7 @@ def test_rewind_song_before_start(self):
800806
mpv_player.rewind()
801807

802808
# check timing is 0
803-
self.assertAlmostEqual(mpv_player.player.time_pos, 0, 0)
809+
self.assertAlmostEqual(mpv_player.player.time_pos, 0, delta=DEFAULT_DELTA)
804810

805811
@func_set_timeout(TIMEOUT)
806812
def test_fast_forward_song(self):
@@ -842,7 +848,11 @@ def test_fast_forward_song(self):
842848
# check timing is later than previously
843849
timing2 = mpv_player.player.time_pos
844850
self.assertGreater(timing2, timing1)
845-
self.assertAlmostEqual(timing2 - timing1, REWIND_FAST_FORWARD_DURATION, 1)
851+
self.assertAlmostEqual(
852+
timing2 - timing1,
853+
REWIND_FAST_FORWARD_DURATION,
854+
delta=REWIND_FAST_FORWARD_DELTA,
855+
)
846856

847857
# assert callback
848858
mpv_player.callbacks["updated_timing"].assert_called_with(

tests/integration/test_media_player_vlc.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
from tests.integration.base import TestCasePollerKara
2121

2222
REWIND_FAST_FORWARD_DURATION = 0.5
23+
REWIND_FAST_FORWARD_DELTA = 0.5
24+
DEFAULT_DELTA = 0.2
2325

2426

2527
@skipUnless(MediaPlayerVlc.is_available(), "VLC not installed")
@@ -525,7 +527,7 @@ def test_restart_song(self):
525527
vlc_player.restart()
526528

527529
# check timing is 0
528-
self.assertAlmostEqual(vlc_player.player.get_time(), 0, 0)
530+
self.assertAlmostEqual(vlc_player.player.get_time(), 0, delta=DEFAULT_DELTA)
529531

530532
# check the song is not stopped
531533
self.assertIsNotNone(vlc_player.playlist_entry)
@@ -683,7 +685,11 @@ def test_rewind_song(self):
683685
# check timing is earlier than previously
684686
timing2 = vlc_player.player.get_time() / 1000
685687
self.assertLess(timing2, timing1)
686-
self.assertAlmostEqual(timing1 - timing2, REWIND_FAST_FORWARD_DURATION, 1)
688+
self.assertAlmostEqual(
689+
timing1 - timing2,
690+
REWIND_FAST_FORWARD_DURATION,
691+
delta=REWIND_FAST_FORWARD_DELTA,
692+
)
687693

688694
@func_set_timeout(TIMEOUT)
689695
def test_rewind_song_before_start(self):
@@ -712,7 +718,7 @@ def test_rewind_song_before_start(self):
712718
vlc_player.rewind()
713719

714720
# check timing is 0
715-
self.assertAlmostEqual(vlc_player.player.get_time(), 0, 0)
721+
self.assertAlmostEqual(vlc_player.player.get_time(), 0, delta=DEFAULT_DELTA)
716722

717723
@func_set_timeout(TIMEOUT)
718724
def test_fast_forward_song(self):
@@ -757,7 +763,11 @@ def test_fast_forward_song(self):
757763
# check timing is earlier than previously
758764
timing2 = vlc_player.player.get_time() / 1000
759765
self.assertGreater(timing2, timing1)
760-
self.assertAlmostEqual(timing2 - timing1, REWIND_FAST_FORWARD_DURATION, 1)
766+
self.assertAlmostEqual(
767+
timing2 - timing1,
768+
REWIND_FAST_FORWARD_DURATION,
769+
delta=REWIND_FAST_FORWARD_DELTA,
770+
)
761771

762772
# assert callback
763773
vlc_player.callbacks["updated_timing"].assert_called_with(

0 commit comments

Comments
 (0)