From 5477a5d039e369e526d14637f4fc3976c0cb9f20 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Sat, 12 Apr 2014 19:04:01 -0700 Subject: [PATCH] better tolerance in RG tests The first fix avoids contaminating all future tests if the plugin fails to load. The second skips the CLI backend tests when the appropriate tool is not available (just as we do with the GStreamer tests). --- test/test_replaygain.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/test/test_replaygain.py b/test/test_replaygain.py index 6996d6525..194b86602 100644 --- a/test/test_replaygain.py +++ b/test/test_replaygain.py @@ -16,6 +16,7 @@ import os import shutil from glob import glob +import subprocess import _common from _common import unittest @@ -36,7 +37,14 @@ class ReplayGainCliTestBase(TestHelper): def setUp(self): self.setup_beets() - self.load_plugins('replaygain') + + try: + self.load_plugins('replaygain') + except: + self.teardown_beets() + self.unload_plugins() + raise + self.config['replaygain']['backend'] = self.backend self.config['plugins'] = ['replaygain'] self.setupLibrary(2) @@ -126,6 +134,20 @@ class ReplayGainGstCliTest(ReplayGainCliTestBase, unittest.TestCase): class ReplayGainCmdCliTest(ReplayGainCliTestBase, unittest.TestCase): backend = u'command' + def setUp(self): + # Check for the backend command. + for command in ['mp3gain', 'aacgain']: + try: + subprocess.check_call([command, '-v']) + except OSError: + pass + else: + break + else: + self.skipTest('no *gain command found') + + super(ReplayGainCmdCliTest, self).setUp() + def suite(): return unittest.TestLoader().loadTestsFromName(__name__)