mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-20 12:40:31 +08:00
Add test for loading preferred plugins.
This commit is contained in:
@@ -24,6 +24,8 @@ plugin_provides = {}
|
||||
plugin_module_name = {}
|
||||
plugin_meta_data = {}
|
||||
|
||||
preferred_plugins = ['matplotlib', 'pil', 'qt', 'freeimage', 'null']
|
||||
|
||||
|
||||
def _clear_plugins():
|
||||
"""Clear the plugin state to the default, i.e., where no plugins are loaded
|
||||
@@ -41,7 +43,6 @@ _clear_plugins()
|
||||
def _load_preferred_plugins():
|
||||
# Load preferred plugin for each io function.
|
||||
io_funcs = ['imsave', 'imshow', 'imread_collection', 'imread']
|
||||
preferred_plugins = ['matplotlib', 'pil', 'qt', 'freeimage', 'null']
|
||||
for func in io_funcs:
|
||||
for plugin in preferred_plugins:
|
||||
if plugin not in available_plugins:
|
||||
|
||||
@@ -30,23 +30,29 @@ def teardown_module():
|
||||
def test_read():
|
||||
io.imread('test.png', as_grey=True, dtype='i4', plugin='test')
|
||||
|
||||
|
||||
def test_save():
|
||||
io.imsave('test.png', [1, 2, 3], plugin='test')
|
||||
|
||||
|
||||
def test_show():
|
||||
io.imshow([1, 2, 3], plugin_arg=(1, 2), plugin='test')
|
||||
|
||||
|
||||
def test_collection():
|
||||
io.imread_collection('*.png', conserve_memory=False, plugin='test')
|
||||
|
||||
|
||||
def test_use():
|
||||
plugin.use_plugin('test')
|
||||
plugin.use_plugin('test', 'imshow')
|
||||
|
||||
|
||||
@raises(ValueError)
|
||||
def test_failed_use():
|
||||
plugin.use_plugin('asd')
|
||||
|
||||
|
||||
@skipif(not PIL_available and not FI_available)
|
||||
def test_use_priority():
|
||||
plugin.use_plugin(priority_plugin)
|
||||
@@ -57,6 +63,7 @@ def test_use_priority():
|
||||
plug, func = plugin.plugin_store['imread'][0]
|
||||
assert_equal(plug, 'test')
|
||||
|
||||
|
||||
@skipif(not PIL_available)
|
||||
def test_use_priority_with_func():
|
||||
plugin.use_plugin('pil')
|
||||
@@ -74,16 +81,26 @@ def test_use_priority_with_func():
|
||||
plug, func = plugin.plugin_store['imsave'][0]
|
||||
assert_equal(plug, 'test')
|
||||
|
||||
|
||||
def test_plugin_order():
|
||||
p = io.plugin_order()
|
||||
assert 'imread' in p
|
||||
assert 'test' in p['imread']
|
||||
|
||||
|
||||
def test_available():
|
||||
assert 'qt' in io.available_plugins
|
||||
assert 'test' in io.find_available_plugins(loaded=True)
|
||||
|
||||
|
||||
def test_load_preferred_plugins():
|
||||
from skimage.io._plugins import null_plugin
|
||||
plugin.preferred_plugins = ['null']
|
||||
plugin.reset_plugins()
|
||||
plug, func = plugin.plugin_store['imshow'][0]
|
||||
assert func == null_plugin.imshow
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from numpy.testing import run_module_suite
|
||||
run_module_suite()
|
||||
|
||||
Reference in New Issue
Block a user