Skip to content

Commit

Permalink
Remove switch about testing special dir in hns bucket (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghua authored Nov 23, 2024
1 parent ee3ac1b commit 84ec6a6
Showing 1 changed file with 37 additions and 38 deletions.
75 changes: 37 additions & 38 deletions tosfs/tests/test_tosfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,44 +427,43 @@ def test_put(tosfs: TosFileSystem, bucket: str, temporary_workspace: str):
) as file:
assert file.read() == "hello world"

if tosfs._is_fns_bucket(bucket):
with tempfile.TemporaryDirectory() as local_temp_dir:
dir_2 = f"{local_temp_dir}/生技??174号文/"
dir_3 = f"{local_temp_dir}/生技**174号文/"
dir_4 = f"{local_temp_dir}/生技_=+&^%#174号文/"
os.makedirs(dir_2)
os.makedirs(dir_3)
os.makedirs(dir_4)
with open(f"{dir_2}/test.txt", "w") as f:
f.write("hello world")
tosfs.put(
local_temp_dir,
f"{bucket}/{temporary_workspace}",
recursive=True,
disable_glob=True,
)
assert tosfs.exists(
f"{bucket}/{temporary_workspace}/{os.path.basename(local_temp_dir)}"
f"/生技??174号文/"
)
assert tosfs.exists(
f"{bucket}/{temporary_workspace}/{os.path.basename(local_temp_dir)}"
f"/生技??174号文/test.txt"
)
assert tosfs.exists(
f"{bucket}/{temporary_workspace}/{os.path.basename(local_temp_dir)}"
f"/生技**174号文/"
)
assert tosfs.exists(
f"{bucket}/{temporary_workspace}/{os.path.basename(local_temp_dir)}"
f"/生技_=+&^%#174号文/"
)
with tosfs.open(
f"{bucket}/{temporary_workspace}/"
f"{os.path.basename(local_temp_dir)}/生技??174号文/test.txt",
mode="r",
) as file:
assert file.read() == "hello world"
with tempfile.TemporaryDirectory() as local_temp_dir:
dir_2 = f"{local_temp_dir}/生技??174号文/"
dir_3 = f"{local_temp_dir}/生技**174号文/"
dir_4 = f"{local_temp_dir}/生技_=+&^%#174号文/"
os.makedirs(dir_2)
os.makedirs(dir_3)
os.makedirs(dir_4)
with open(f"{dir_2}/test.txt", "w") as f:
f.write("hello world")
tosfs.put(
local_temp_dir,
f"{bucket}/{temporary_workspace}",
recursive=True,
disable_glob=True,
)
assert tosfs.exists(
f"{bucket}/{temporary_workspace}/{os.path.basename(local_temp_dir)}"
f"/生技??174号文/"
)
assert tosfs.exists(
f"{bucket}/{temporary_workspace}/{os.path.basename(local_temp_dir)}"
f"/生技??174号文/test.txt"
)
assert tosfs.exists(
f"{bucket}/{temporary_workspace}/{os.path.basename(local_temp_dir)}"
f"/生技**174号文/"
)
assert tosfs.exists(
f"{bucket}/{temporary_workspace}/{os.path.basename(local_temp_dir)}"
f"/生技_=+&^%#174号文/"
)
with tosfs.open(
f"{bucket}/{temporary_workspace}/"
f"{os.path.basename(local_temp_dir)}/生技??174号文/test.txt",
mode="r",
) as file:
assert file.read() == "hello world"

# test let special-char dir as the lpath
with tempfile.TemporaryDirectory() as local_temp_dir:
Expand Down

0 comments on commit 84ec6a6

Please sign in to comment.