File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
nibabel/streamlines/tests Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ def setup():
84
84
)
85
85
86
86
87
- def test_is_supported_detect_format ():
87
+ def test_is_supported_detect_format (tmp_path ):
88
88
# Test is_supported and detect_format functions
89
89
# Empty file/string
90
90
f = BytesIO ()
@@ -103,15 +103,17 @@ def test_is_supported_detect_format():
103
103
104
104
# Wrong extension but right magic number
105
105
for tfile_cls in FORMATS .values ():
106
- with tempfile .TemporaryFile (mode = 'w+b' , suffix = '.txt' ) as f :
106
+ fpath = tmp_path / 'test.txt'
107
+ with open (fpath , 'w+b' ) as f :
107
108
f .write (asbytes (tfile_cls .MAGIC_NUMBER ))
108
109
f .seek (0 , os .SEEK_SET )
109
110
assert nib .streamlines .is_supported (f )
110
111
assert nib .streamlines .detect_format (f ) is tfile_cls
111
112
112
113
# Good extension but wrong magic number
113
114
for ext , tfile_cls in FORMATS .items ():
114
- with tempfile .TemporaryFile (mode = 'w+b' , suffix = ext ) as f :
115
+ fpath = tmp_path / f'test{ ext } '
116
+ with open (fpath , 'w+b' ) as f :
115
117
f .write (b'pass' )
116
118
f .seek (0 , os .SEEK_SET )
117
119
assert not nib .streamlines .is_supported (f )
You can’t perform that action at this time.
0 commit comments