Skip to content

Commit 6061651

Browse files
committed
TEST/RF: Mock compress_ext_map, instead of fixture
1 parent a7f8e11 commit 6061651

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

nibabel/tests/test_openers.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from ..tmpdirs import InTemporaryDirectory
1919
from ..volumeutils import BinOpener
2020

21+
import unittest
2122
from unittest import mock
2223
import pytest
2324
from ..testing import error_warnings
@@ -160,19 +161,8 @@ def test_Opener_gzip_type():
160161
with patch_indexed_gzip(igzip_present):
161162
assert isinstance(Opener(fname, **kwargs).fobj, expected)
162163

163-
@pytest.fixture(scope="class")
164-
def image_opener_setup(request):
165-
compress_ext_map = ImageOpener.compress_ext_map.copy()
166-
request.cls.compress_ext_map = compress_ext_map
167-
168-
def teardown():
169-
ImageOpener.compress_ext_map = request.cls.compress_ext_map
170-
request.addfinalizer(teardown)
171-
172-
173-
@pytest.mark.usefixtures("image_opener_setup")
174-
class TestImageOpener:
175164

165+
class TestImageOpener(unittest.TestCase):
176166
def test_vanilla(self):
177167
# Test that ImageOpener does add '.mgz' as gzipped file type
178168
with InTemporaryDirectory():
@@ -181,6 +171,7 @@ def test_vanilla(self):
181171
with ImageOpener('test.mgz', 'w') as fobj:
182172
assert hasattr(fobj.fobj, 'compress')
183173

174+
@mock.patch.dict('nibabel.openers.ImageOpener.compress_ext_map')
184175
def test_new_association(self):
185176
def file_opener(fileish, mode):
186177
return open(fileish, mode)

0 commit comments

Comments
 (0)