From a1552dbe734377c5aace080a4166ddea13d0bd4c Mon Sep 17 00:00:00 2001 From: Sumner Evans Date: Mon, 6 Jul 2020 16:59:07 -0600 Subject: [PATCH] Try to get MPV tests working on null audio device --- .gitlab-ci.yml | 2 -- sublime/players/mpv.py | 4 ++++ tests/player_tests/mpv_tests.py | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 39cf61a..a404a02 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -36,8 +36,6 @@ test: - apt install xvfb - Xvfb :119 -screen 0 1024x768x16 & - export DISPLAY=:119 - - pulseaudio -D --system --exit-idle-time=-1 - - pactl load-module module-null-sink sink_name=DummyOutput sink_properties=device.description="Virtual_Dummy_Output" script: - pipenv run ./cicd/pytest.sh artifacts: diff --git a/sublime/players/mpv.py b/sublime/players/mpv.py index 9506b6a..d5d1db3 100644 --- a/sublime/players/mpv.py +++ b/sublime/players/mpv.py @@ -24,6 +24,8 @@ class MPVPlayer(Player): _volume = 100.0 _muted = False + _is_mock = False + @staticmethod def get_configuration_options() -> Dict[str, Union[Type, Tuple[str, ...]]]: return {REPLAY_GAIN_KEY: ("Disabled", "Track", "Album")} @@ -37,6 +39,8 @@ class MPVPlayer(Player): config: Dict[str, Union[str, int, bool]], ): self.mpv = mpv.MPV() + if MPVPlayer._is_mock: + self.mpv.audio_device = "null" self.mpv.audio_client_name = "sublime-music" self.change_settings(config) diff --git a/tests/player_tests/mpv_tests.py b/tests/player_tests/mpv_tests.py index b445c7e..38f5ed8 100644 --- a/tests/player_tests/mpv_tests.py +++ b/tests/player_tests/mpv_tests.py @@ -4,6 +4,8 @@ from time import sleep from sublime.players.mpv import MPVPlayer +MPVPlayer._is_mock = True + def test_init(): empty_fn = lambda *a, **k: None