mirror of
https://github.com/beetbox/beets.git
synced 2025-12-22 08:34:23 +01:00
Skip GStreamer tests if plugins are missing
* Add a check to ReplayGainGstCliTest that ensures that the required initial gstreamer plugins can be loaded, skipping the test if it is not the case instead of running it. * Add a check to ReplayGainGstCliTest.test_cli_saves_track_gain for checking if item.rg_track_peak and item.rg_track_gain is not None. If they are None, it is assumed that the decoder plugins could not be found, and the tests is skipped, as discussed on #1830.
This commit is contained in:
parent
5f8e710e07
commit
d2cec48c65
1 changed files with 23 additions and 0 deletions
|
|
@ -20,7 +20,9 @@ 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 FatalReplayGainError, GStreamerBackend
|
||||
|
||||
try:
|
||||
import gi
|
||||
|
|
@ -87,6 +89,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 +141,20 @@ 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 FatalReplayGainError as e:
|
||||
# Skip the test if plugins could not be loaded.
|
||||
if str(e) == "Failed to load required GStreamer plugins":
|
||||
self.skipTest(str(e))
|
||||
else:
|
||||
raise 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