From f8e2ca2c944d5dd2c1d7cec46372d0098192ec1b Mon Sep 17 00:00:00 2001 From: Bruno Cauet Date: Wed, 4 Mar 2015 12:15:56 +0100 Subject: [PATCH] Replaygain tests: more careful plugins unloading When plugins loading as failed plugins unloading may fail in consequence, swallowing the loading error. This fixes it. --- test/test_replaygain.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/test/test_replaygain.py b/test/test_replaygain.py index 64d65b006..2c623725c 100644 --- a/test/test_replaygain.py +++ b/test/test_replaygain.py @@ -42,9 +42,18 @@ class ReplayGainCliTestBase(TestHelper): try: self.load_plugins('replaygain') except: - self.teardown_beets() - self.unload_plugins() - raise + import sys + # store exception info so an error in teardown does not swallow it + exc_info = sys.exc_info() + try: + self.teardown_beets() + self.unload_plugins() + except: + # if load_plugins() failed then setup is incomplete and + # teardown operations may fail. In particular # {Item,Album} + # may not have the _original_types attribute in unload_plugins + pass + raise exc_info[1], None, exc_info[2] self.config['replaygain']['backend'] = self.backend album = self.add_album_fixture(2)