Merge pull request #4244 from wisp3rwind/pr_fix_reraise

Fix exception handling in tests
This commit is contained in:
Benedikt 2022-01-20 23:41:33 +01:00 committed by GitHub
commit 2744e593f6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 21 deletions

View file

@ -175,7 +175,7 @@ class ConcurrentEventsTest(TestCase, helper.TestHelper):
self.lock1 = threading.Lock()
self.lock2 = threading.Lock()
self.test_case = test_case
self.exc_info = None
self.exc = None
self.t1_step = self.t2_step = 0
def log_all(self, name):
@ -190,9 +190,8 @@ class ConcurrentEventsTest(TestCase, helper.TestHelper):
self.lock1.acquire()
self.test_case.assertEqual(self._log.level, log.INFO)
self.t1_step = 2
except Exception:
import sys
self.exc_info = sys.exc_info()
except Exception as e:
self.exc = e
def listener2(self):
try:
@ -201,9 +200,8 @@ class ConcurrentEventsTest(TestCase, helper.TestHelper):
self.lock2.acquire()
self.test_case.assertEqual(self._log.level, log.DEBUG)
self.t2_step = 2
except Exception:
import sys
self.exc_info = sys.exc_info()
except Exception as e:
self.exc = e
def setUp(self):
self.setup_beets(disk=True)
@ -215,8 +213,8 @@ class ConcurrentEventsTest(TestCase, helper.TestHelper):
dp = self.DummyPlugin(self)
def check_dp_exc():
if dp.exc_info:
raise None.with_traceback(dp.exc_info[2])
if dp.exc:
raise dp.exc
try:
dp.lock1.acquire()

View file

@ -55,18 +55,8 @@ class ReplayGainCliTestBase(TestHelper):
try:
self.load_plugins('replaygain')
except Exception:
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 Exception:
# 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 None.with_traceback(exc_info[2])
self.teardown_beets()
self.unload_plugins()
album = self.add_album_fixture(2)
for item in album.items():