Skip to content

Commit 9758d55

Browse files
committed
TEST: Test invalid KEEP_FILE_OPEN_DEFAULT values
1 parent f6d9992 commit 9758d55

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

nibabel/tests/test_arrayproxy.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -467,12 +467,14 @@ def test_keep_file_open_true_false_invalid():
467467
fname = 'testdata'
468468
with open(fname, 'wb') as fobj:
469469
fobj.write(data.tostring(order='F'))
470-
with assert_raises(ValueError):
471-
ArrayProxy(fname, ((10, 10, 10), dtype), keep_file_open=55)
472-
with assert_raises(ValueError):
473-
ArrayProxy(fname, ((10, 10, 10), dtype), keep_file_open='auto')
474-
with assert_raises(ValueError):
475-
ArrayProxy(fname, ((10, 10, 10), dtype), keep_file_open='cauto')
470+
471+
for invalid_kfo in (55, 'auto', 'cauto'):
472+
with assert_raises(ValueError):
473+
ArrayProxy(fname, ((10, 10, 10), dtype),
474+
keep_file_open=invalid_kfo)
475+
with patch_keep_file_open_default(invalid_kfo):
476+
with assert_raises(ValueError):
477+
ArrayProxy(fname, ((10, 10, 10), dtype))
476478

477479

478480
def test_pickle_lock():

0 commit comments

Comments
 (0)