mirror of
https://github.com/beetbox/beets.git
synced 2025-12-26 02:24:33 +01:00
Merge pull request #1836 from diego-plan9/gstreamertest
Skip GStreamer tests if plugins are missing
This commit is contained in:
commit
db7fffbdcc
2 changed files with 28 additions and 1 deletions
|
|
@ -43,6 +43,11 @@ class FatalReplayGainError(Exception):
|
|||
"""
|
||||
|
||||
|
||||
class FatalGstreamerPluginReplayGainError(FatalReplayGainError):
|
||||
"""Raised when a fatal error occurs in the GStreamerBackend when
|
||||
loading the required plugins."""
|
||||
|
||||
|
||||
def call(args):
|
||||
"""Execute the command and return its output or raise a
|
||||
ReplayGainError on failure.
|
||||
|
|
@ -391,7 +396,7 @@ class GStreamerBackend(Backend):
|
|||
|
||||
if self._src is None or self._decbin is None or self._conv is None \
|
||||
or self._res is None or self._rg is None:
|
||||
raise FatalReplayGainError(
|
||||
raise FatalGstreamerPluginReplayGainError(
|
||||
"Failed to load required GStreamer plugins"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,10 @@ from __future__ import (division, absolute_import, print_function,
|
|||
from test._common import unittest
|
||||
from test.helper import TestHelper, has_program
|
||||
|
||||
from beets import config
|
||||
from beets.mediafile import MediaFile
|
||||
from beetsplug.replaygain import (FatalGstreamerPluginReplayGainError,
|
||||
GStreamerBackend)
|
||||
|
||||
try:
|
||||
import gi
|
||||
|
|
@ -87,6 +90,13 @@ class ReplayGainCliTestBase(TestHelper):
|
|||
self.assertIsNone(mediafile.rg_track_gain)
|
||||
|
||||
self.run_command('replaygain')
|
||||
|
||||
# Skip the test if rg_track_peak and rg_track gain is None, assuming
|
||||
# that it could only happen if the decoder plugins are missing.
|
||||
if all(i.rg_track_peak is None and i.rg_track_gain is None
|
||||
for i in self.lib.items()):
|
||||
self.skipTest('decoder plugins could not be loaded.')
|
||||
|
||||
for item in self.lib.items():
|
||||
self.assertIsNotNone(item.rg_track_peak)
|
||||
self.assertIsNotNone(item.rg_track_gain)
|
||||
|
|
@ -132,6 +142,18 @@ class ReplayGainCliTestBase(TestHelper):
|
|||
class ReplayGainGstCliTest(ReplayGainCliTestBase, unittest.TestCase):
|
||||
backend = u'gstreamer'
|
||||
|
||||
def setUp(self):
|
||||
try:
|
||||
# Check if required plugins can be loaded by instantiating a
|
||||
# GStreamerBackend (via its .__init__).
|
||||
config['replaygain']['targetlevel'] = 89
|
||||
GStreamerBackend(config['replaygain'], None)
|
||||
except FatalGstreamerPluginReplayGainError as e:
|
||||
# Skip the test if plugins could not be loaded.
|
||||
self.skipTest(str(e))
|
||||
|
||||
super(ReplayGainGstCliTest, self).setUp()
|
||||
|
||||
|
||||
@unittest.skipIf(not GAIN_PROG_AVAILABLE, 'no *gain command found')
|
||||
class ReplayGainCmdCliTest(ReplayGainCliTestBase, unittest.TestCase):
|
||||
|
|
|
|||
Loading…
Reference in a new issue