def test_changedt(create_files_in_directory_plus_output_type): files, testdir, out_ext = create_files_in_directory_plus_output_type # Get some fslmaths cdt = fsl.ChangeDataType() # Test that we got what we wanted assert cdt.cmd == "fslmaths" # Test that it needs a mandatory argument with pytest.raises(ValueError): cdt.run() # Set an in file and out file cdt.inputs.in_file = "a.nii" cdt.inputs.out_file = "b.nii" # But it still shouldn't work with pytest.raises(ValueError): cdt.run() # Now test that we can set the various data types dtypes = ["float", "char", "int", "short", "double", "input"] cmdline = "fslmaths a.nii b.nii -odt {}" for dtype in dtypes: foo = fsl.MathsCommand(in_file="a.nii", out_file="b.nii", output_datatype=dtype) assert foo.cmdline == cmdline.format(dtype)
def test_changedt(fsl_output_type=None): prev_type = set_output_type(fsl_output_type) files, testdir, origdir, out_ext = create_files_in_directory() # Get some fslmaths cdt = fsl.ChangeDataType() # Test that we got what we wanted yield assert_equal, cdt.cmd, "fslmaths" # Test that it needs a mandatory argument yield assert_raises, ValueError, cdt.run # Set an in file and out file cdt.inputs.in_file = "a.nii" cdt.inputs.out_file = "b.nii" # But it still shouldn't work yield assert_raises, ValueError, cdt.run # Now test that we can set the various data types dtypes = ["float", "char", "int", "short", "double", "input"] cmdline = "fslmaths a.nii b.nii -odt %s" for dtype in dtypes: foo = fsl.MathsCommand(in_file="a.nii", out_file="b.nii", output_datatype=dtype) yield assert_equal, foo.cmdline, cmdline % dtype # Clean up our mess clean_directory(testdir, origdir) set_output_type(prev_type)