Skip to content

Commit 891e462

Browse files
Maintain relative path behavior
1 parent f1f9901 commit 891e462

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

nibabel/filename_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def _stringify_path(filepath_or_buffer: FileSpec) -> str:
3838
Adapted from:
3939
https://github.com/pandas-dev/pandas/blob/325dd68/pandas/io/common.py#L131-L160
4040
"""
41-
return str(pathlib.Path(filepath_or_buffer).expanduser().resolve())
41+
return str(pathlib.Path(filepath_or_buffer).expanduser())
4242

4343

4444
def types_filenames(

nibabel/tests/test_filename_parser.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,21 +128,19 @@ def test_splitext_addext():
128128

129129
def test__stringify_path():
130130
current_directory = pathlib.Path.cwd()
131-
res = _stringify_path('')
132-
assert res == str(current_directory)
133131
res = _stringify_path('fname.ext.gz')
134-
assert res == str(current_directory / 'fname.ext.gz')
132+
assert res == 'fname.ext.gz'
135133
res = _stringify_path(pathlib.Path('fname.ext.gz'))
136-
assert res == str(current_directory / 'fname.ext.gz')
134+
assert res == 'fname.ext.gz'
137135

138136
home = pathlib.Path.home()
139137
res = _stringify_path(pathlib.Path('~/fname.ext.gz'))
140138
assert res == str(home) + '/fname.ext.gz'
141139

142140
res = _stringify_path(pathlib.Path('./fname.ext.gz'))
143-
assert res == str(current_directory / 'fname.ext.gz')
141+
assert res == 'fname.ext.gz'
144142
res = _stringify_path(pathlib.Path('../fname.ext.gz'))
145-
assert res == str(current_directory.parent / 'fname.ext.gz')
143+
assert res == '../fname.ext.gz'
146144

147145

148146

0 commit comments

Comments
 (0)