Skip to content

Commit b4db866

Browse files
committed
TEST: Change unit test arrayproxy mocks - no longer necessary.
1 parent b5111b5 commit b4db866

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

nibabel/benchmarks/bench_arrayproxy_slicing.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@
6262
@contextlib.contextmanager
6363
def patch_indexed_gzip(have_igzip):
6464

65-
atts = ['nibabel.openers.HAVE_INDEXED_GZIP',
66-
'nibabel.arrayproxy.HAVE_INDEXED_GZIP']
65+
atts = ['nibabel.openers.HAVE_INDEXED_GZIP']
6766

6867
with mock.patch(atts[0], have_igzip), mock.patch(atts[1], have_igzip):
6968
yield

nibabel/tests/test_arrayproxy.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ def test_keep_file_open_true_false_invalid():
369369
# Test that ArrayProxy(keep_file_open=True) only creates one file
370370
# handle, and that ArrayProxy(keep_file_open=False) creates a file
371371
# handle on every data access.
372-
with mock.patch('nibabel.arrayproxy.ImageOpener', CountingImageOpener):
372+
with mock.patch('nibabel.openers.ImageOpener', CountingImageOpener):
373373
proxy_no_kfp = ArrayProxy(fname, ((10, 10, 10), dtype),
374374
keep_file_open=False)
375375
assert not proxy_no_kfp._keep_file_open
@@ -418,15 +418,15 @@ def test_keep_file_open_auto():
418418
# If have_indexed_gzip, then the arrayproxy should create one
419419
# ImageOpener
420420
with patch_indexed_gzip(True), \
421-
mock.patch('nibabel.arrayproxy.ImageOpener', CountingImageOpener):
421+
mock.patch('nibabel.openers.ImageOpener', CountingImageOpener):
422422
CountingImageOpener.num_openers = 0
423423
proxy = ArrayProxy(fname, ((10, 10, 10), dtype),
424424
keep_file_open='auto')
425425
assert proxy._keep_file_open == 'auto'
426426
assert _count_ImageOpeners(proxy, data, voxels) == 1
427427
# If no have_indexed_gzip, then keep_file_open should be False
428428
with patch_indexed_gzip(False), \
429-
mock.patch('nibabel.arrayproxy.ImageOpener', CountingImageOpener):
429+
mock.patch('nibabel.openers.ImageOpener', CountingImageOpener):
430430
CountingImageOpener.num_openers = 0
431431
proxy = ArrayProxy(fname, ((10, 10, 10), dtype),
432432
keep_file_open='auto')
@@ -438,14 +438,14 @@ def test_keep_file_open_auto():
438438
fobj.write(data.tostring(order='F'))
439439
# regardless of whether indexed_gzip is present or not
440440
with patch_indexed_gzip(True), \
441-
mock.patch('nibabel.arrayproxy.ImageOpener', CountingImageOpener):
441+
mock.patch('nibabel.openers.ImageOpener', CountingImageOpener):
442442
CountingImageOpener.num_openers = 0
443443
proxy = ArrayProxy(fname, ((10, 10, 10), dtype),
444444
keep_file_open='auto')
445445
assert proxy._keep_file_open is False
446446
assert _count_ImageOpeners(proxy, data, voxels) == 10
447447
with patch_indexed_gzip(False), \
448-
mock.patch('nibabel.arrayproxy.ImageOpener', CountingImageOpener):
448+
mock.patch('nibabel.openers.ImageOpener', CountingImageOpener):
449449
CountingImageOpener.num_openers = 0
450450
proxy = ArrayProxy(fname, ((10, 10, 10), dtype),
451451
keep_file_open='auto')

nibabel/tests/test_openers.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,11 @@ def patch_indexed_gzip(state):
108108
# Make it look like we do (state==True) or do not (state==False) have
109109
# the indexed gzip module.
110110
if state:
111-
values = (True, True, MockIndexedGzipFile)
111+
values = (True, MockIndexedGzipFile)
112112
else:
113-
values = (False, False, GzipFile)
113+
values = (False, GzipFile)
114114
with mock.patch('nibabel.openers.HAVE_INDEXED_GZIP', values[0]), \
115-
mock.patch('nibabel.arrayproxy.HAVE_INDEXED_GZIP', values[1]), \
116-
mock.patch('nibabel.openers.IndexedGzipFile', values[2],
115+
mock.patch('nibabel.openers.IndexedGzipFile', values[1],
117116
create=True):
118117
yield
119118

0 commit comments

Comments
 (0)