mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-08 23:43:13 +08:00
Clean up test
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
import warnings
|
||||
from contextlib import contextmanager
|
||||
|
||||
import numpy as np
|
||||
from numpy.testing import raises
|
||||
@@ -8,35 +9,38 @@ from skimage import io
|
||||
from skimage import data_dir
|
||||
|
||||
|
||||
@contextmanager
|
||||
def warnings_as_errors():
|
||||
# Temporarily set warnings as errors so we can test the warning is raised.
|
||||
with warnings.catch_warnings():
|
||||
warnings.filterwarnings('error')
|
||||
yield
|
||||
|
||||
@raises(Warning)
|
||||
def test_null_imread():
|
||||
path = os.path.join(data_dir, 'color.png')
|
||||
with warnings.catch_warnings(): # Temporarily set warnings as errors.
|
||||
warnings.filterwarnings('error')
|
||||
with warnings_as_errors():
|
||||
io.imread(path, plugin='null')
|
||||
|
||||
|
||||
@raises(Warning)
|
||||
def test_null_imsave():
|
||||
with warnings.catch_warnings(): # Temporarily set warnings as errors.
|
||||
warnings.filterwarnings('error')
|
||||
with warnings_as_errors():
|
||||
io.imsave('dummy.png', np.zeros((3, 3)), plugin='null')
|
||||
|
||||
|
||||
@raises(Warning)
|
||||
def test_null_imshow():
|
||||
with warnings.catch_warnings(): # Temporarily set warnings as errors.
|
||||
warnings.filterwarnings('error')
|
||||
with warnings_as_errors():
|
||||
io.imshow(np.zeros((3, 3)), plugin='null')
|
||||
|
||||
|
||||
@raises(Warning)
|
||||
def test_null_imread_collection():
|
||||
# Note that the null plugin doesn't define an `imread_collection` plugin
|
||||
# but this function dynamically added by the plugin manager.
|
||||
# but this function is dynamically added by the plugin manager.
|
||||
path = os.path.join(data_dir, '*.png')
|
||||
with warnings.catch_warnings(): # Temporarily set warnings as errors.
|
||||
warnings.filterwarnings('error')
|
||||
with warnings_as_errors():
|
||||
collection = io.imread_collection(path, plugin='null')
|
||||
collection[0]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user