From db4cc04a900f3732f8409478dfd3784de67a33c0 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Fri, 20 Jul 2012 15:46:58 -0400 Subject: [PATCH] BUG: Fix tests when FreeImage is not installed. The plugin loader tries plugins but only catches ImportError and RuntimeError. The FreeImage plugin was throwing OSError. Tests were failing when FreeImage was not installed. It now throws a RuntimeError. --- skimage/io/_plugins/freeimage_plugin.py | 4 ++-- skimage/io/tests/test_freeimage.py | 4 ++-- skimage/io/tests/test_plugin.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/skimage/io/_plugins/freeimage_plugin.py b/skimage/io/_plugins/freeimage_plugin.py index 6475781b..af611250 100644 --- a/skimage/io/_plugins/freeimage_plugin.py +++ b/skimage/io/_plugins/freeimage_plugin.py @@ -72,12 +72,12 @@ def load_freeimage(): # No freeimage library loaded, and load-errors reported for some # candidate libs err_txt = ['%s:\n%s' % (l, str(e.message)) for l, e in errors] - raise OSError('One or more FreeImage libraries were found, but ' + raise RuntimeError('One or more FreeImage libraries were found, but ' 'could not be loaded due to the following errors:\n' '\n\n'.join(err_txt)) else: # No errors, because no potential libraries found at all! - raise OSError('Could not find a FreeImage library in any of:\n' + + raise RuntimeError('Could not find a FreeImage library in any of:\n' + '\n'.join(lib_dirs)) # FreeImage found diff --git a/skimage/io/tests/test_freeimage.py b/skimage/io/tests/test_freeimage.py index 565f37bd..7a294f9e 100644 --- a/skimage/io/tests/test_freeimage.py +++ b/skimage/io/tests/test_freeimage.py @@ -11,7 +11,7 @@ try: import skimage.io._plugins.freeimage_plugin as fi FI_available = True sio.use_plugin('freeimage') -except OSError: +except RuntimeError: FI_available = False @@ -23,7 +23,7 @@ def setup_module(self): """ try: sio.use_plugin('freeimage') - except OSError: + except RuntimeError: pass diff --git a/skimage/io/tests/test_plugin.py b/skimage/io/tests/test_plugin.py index 28d8c2b3..5d1febe4 100644 --- a/skimage/io/tests/test_plugin.py +++ b/skimage/io/tests/test_plugin.py @@ -15,7 +15,7 @@ try: io.use_plugin('freeimage') FI_available = True priority_plugin = 'freeimage' -except OSError: +except RuntimeError: FI_available = False