From 2f699da7435b86143369fff0d21253753de3a834 Mon Sep 17 00:00:00 2001 From: vinoyang Date: Tue, 15 Oct 2024 16:44:36 +0800 Subject: [PATCH] Add test for size API (#196) --- tosfs/tests/test_fsspec.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tosfs/tests/test_fsspec.py b/tosfs/tests/test_fsspec.py index 339ec56..44779c7 100644 --- a/tosfs/tests/test_fsspec.py +++ b/tosfs/tests/test_fsspec.py @@ -875,3 +875,14 @@ def test_tail(fsspecfs: Any, bucket: str, temporary_workspace: str): with pytest.raises(IsADirectoryError): fsspecfs.tail(path, 3) + + +def test_size(fsspecfs: Any, bucket: str, temporary_workspace: str): + file_name = random_str() + path = f"{bucket}/{temporary_workspace}/{file_name}" + content = "hello world" + with fsspecfs.open(path, "w") as f: + f.write(content) + + assert fsspecfs.size(path) == len(content) + assert fsspecfs.size(f"{bucket}/{temporary_workspace}") == 0