@@ -13,10 +13,12 @@ def remote():
1313 ├── data
1414 │ ├── alice
1515 │ ├── alpha
16+ │ ├── subdir-file.txt
1617 │ └── subdir
1718 │ ├── 1
1819 │ ├── 2
1920 │ └── 3
21+ ├── data1.txt
2022 ├── empty_dir
2123 ├── empty_file
2224 └── foo
@@ -26,6 +28,7 @@ def remote():
2628 s3 = remote .s3
2729
2830 s3 .create_bucket (Bucket = "bucket" )
31+ s3 .put_object (Bucket = "bucket" , Key = "data1.txt" , Body = b"" )
2932 s3 .put_object (Bucket = "bucket" , Key = "empty_dir/" )
3033 s3 .put_object (Bucket = "bucket" , Key = "empty_file" , Body = b"" )
3134 s3 .put_object (Bucket = "bucket" , Key = "foo" , Body = b"foo" )
@@ -34,6 +37,9 @@ def remote():
3437 s3 .put_object (Bucket = "bucket" , Key = "data/subdir/1" , Body = b"1" )
3538 s3 .put_object (Bucket = "bucket" , Key = "data/subdir/2" , Body = b"2" )
3639 s3 .put_object (Bucket = "bucket" , Key = "data/subdir/3" , Body = b"3" )
40+ s3 .put_object (
41+ Bucket = "bucket" , Key = "data/subdir-file.txt" , Body = b"subdir"
42+ )
3743
3844 yield remote
3945
@@ -66,6 +72,7 @@ def test_exists(remote):
6672 (True , "data/subdir/1" ),
6773 (False , "data/al" ),
6874 (False , "foo/" ),
75+ (True , "data1.txt" ),
6976 ]
7077
7178 for expected , path in test_cases :
@@ -76,9 +83,11 @@ def test_walk_files(remote):
7683 files = [
7784 remote .path_info / "data/alice" ,
7885 remote .path_info / "data/alpha" ,
86+ remote .path_info / "data/subdir-file.txt" ,
7987 remote .path_info / "data/subdir/1" ,
8088 remote .path_info / "data/subdir/2" ,
8189 remote .path_info / "data/subdir/3" ,
90+ remote .path_info / "data1.txt" ,
8291 remote .path_info / "empty_file" ,
8392 remote .path_info / "foo" ,
8493 ]
@@ -109,3 +118,23 @@ def test_makedirs(remote):
109118 assert not remote .exists (empty_dir )
110119 remote .makedirs (empty_dir )
111120 assert remote .exists (empty_dir )
121+
122+
123+ def test_isfile (remote ):
124+ test_cases = [
125+ (False , "empty_dir/" ),
126+ (True , "empty_file" ),
127+ (True , "foo" ),
128+ (True , "data/alice" ),
129+ (True , "data/alpha" ),
130+ (True , "data/subdir/1" ),
131+ (True , "data/subdir/2" ),
132+ (True , "data/subdir/3" ),
133+ (False , "data/subdir/empty_dir/" ),
134+ (False , "data/subdir/1/" ),
135+ (False , "something-that-does-not-exist" ),
136+ (False , "empty_dir" ),
137+ ]
138+
139+ for expected , path in test_cases :
140+ assert remote .isfile (remote .path_info / path ) == expected
0 commit comments