From 810a350722cdc69d297b0d4c8ce580322a6bc233 Mon Sep 17 00:00:00 2001 From: yanghua Date: Mon, 18 Nov 2024 20:52:57 +0800 Subject: [PATCH] Remove switch about testing special dir in hns bucket --- tosfs/tests/test_tosfs.py | 75 +++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/tosfs/tests/test_tosfs.py b/tosfs/tests/test_tosfs.py index efdc344..597137a 100644 --- a/tosfs/tests/test_tosfs.py +++ b/tosfs/tests/test_tosfs.py @@ -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: