Skip to content

Commit

Permalink
Replace deprecated nose style setup/teardown with autouse fixtures (#…
Browse files Browse the repository at this point in the history
…7343)

methods with autouse fixtures. The nose style is no longer supported by
pytest since version 7.2.

https://docs.pytest.org/en/latest/deprecations.html#nose-deprecation

Also remove unnecessary calls to setup_test and teardown_tests 
in rank/tests. These are called in skimage/conftest.py already and I
don't see a reason to call them again in rank/tests specifically..
  • Loading branch information
lagru committed Apr 23, 2024
1 parent 885dd39 commit 5468c24
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions skimage/io/tests/test_imread.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
fetch,
)

from pytest import importorskip
import pytest

importorskip('imread')
pytest.importorskip('imread')


def setup():
@pytest.fixture(autouse=True)
def _use_imread_plugin():
"""Ensure that PIL plugin is used in tests here."""
use_plugin('imread')


def teardown():
yield
reset_plugins()


Expand Down
3 changes: 2 additions & 1 deletion skimage/io/tests/test_mpl_imshow.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
plt = pytest.importorskip("matplotlib.pyplot")


def setup():
@pytest.fixture(autouse=True)
def _reset_plugins():
io.reset_plugins()


Expand Down
7 changes: 3 additions & 4 deletions skimage/io/tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
priority_plugin = 'pil'


def setup():
@pytest.fixture(autouse=True)
def _use_pil_plugin():
io.use_plugin('pil')


def teardown_module():
yield
io.reset_plugins()


Expand Down
8 changes: 4 additions & 4 deletions skimage/io/tests/test_tifffile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
from skimage.io import imread, imsave, reset_plugins, use_plugin


def setup():
@pytest.fixture(autouse=True)
def _use_tifffile_plugin():
"""Ensure that PIL plugin is used in tests here."""
use_plugin('tifffile')
np.random.seed(0)


def teardown():
yield
reset_plugins()


Expand Down

0 comments on commit 5468c24

Please sign in to comment.