Skip to content

Commit ddce800

Browse files
committed
TEST: Verify --force overwrites
1 parent 3751f61 commit ddce800

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

nibabel/cmdline/tests/test_convert.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,22 @@ def test_convert_noop(tmp_path):
3232
assert converted.shape == orig.shape
3333
assert converted.get_data_dtype() == orig.get_data_dtype()
3434

35+
infile = test_data(fname='resampled_anat_moved.nii')
36+
3537
with pytest.raises(FileExistsError):
3638
convert.main([str(infile), str(outfile)])
3739

3840
convert.main([str(infile), str(outfile), '--force'])
3941
assert outfile.is_file()
4042

43+
# Verify that we did overwrite
44+
converted2 = nib.load(outfile)
45+
assert not (
46+
converted2.shape == converted.shape
47+
and np.allclose(converted2.affine, converted.affine)
48+
and np.allclose(converted2.get_fdata(), converted.get_fdata())
49+
)
50+
4151

4252
@pytest.mark.parametrize('data_dtype', ('u1', 'i2', 'float32', 'float', 'int64'))
4353
def test_convert_dtype(tmp_path, data_dtype):

0 commit comments

Comments
 (0)