Skip to content

Commit fae7605

Browse files
improve code
co-authored by @adswa, @bpoldrack Use suggestions by Ben and Adina to improve the code Rebased on main
1 parent f73b17f commit fae7605

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

datalad_dataverse/tests/test_dataset.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
At least as long as we are using that API layer.
55
"""
66

7-
from pathlib import (
8-
Path,
9-
PurePosixPath,
10-
)
7+
from pathlib import PurePosixPath
118
import json
129

1310
from datalad_next.tests.utils import md5sum
@@ -36,8 +33,7 @@ def test_file_handling(
3633

3734
path_info = dict()
3835
for path in paths:
39-
if path.parent != tmp_path:
40-
path.parent.mkdir()
36+
path.parent.mkdir(parents=True, exist_ok=True)
4137
relative_path = path.relative_to(tmp_path)
4238
fcontent = 'content of: ' + str(relative_path)
4339
path.write_text(fcontent)
@@ -54,14 +50,15 @@ def test_file_handling(
5450
path_to_check = relative_path.parent / 'mykey'
5551
fileid = check_replace_file(odd, fileid, path_to_check, tmp_path)
5652
check_rename_file(
57-
odd, fileid, name=str(relative_path.parent / ('ren' + path.name))
53+
odd, fileid,
54+
name=PurePosixPath(relative_path.parent / ('ren' + path.name))
5855
)
5956
check_remove(odd, fileid, PurePosixPath(path.name))
6057
check_duplicate_file_deposition(odd, tmp_path)
6158

6259

63-
def check_rename_file(odd, fileid, name='place.txt'):
64-
new_path = PurePosixPath(*(('fresh',) + Path(name).parts))
60+
def check_rename_file(odd, fileid, name=PurePosixPath('place.txt')):
61+
new_path = PurePosixPath('fresh' / name)
6562
assert not odd.has_path(new_path)
6663
assert odd.has_fileid(fileid)
6764
odd.rename_file(new_path, fileid)

0 commit comments

Comments
 (0)