@@ -1348,3 +1348,40 @@ def test_find_with_prefix(storage):
13481348 assert test_1s == [test_bucket_name + "/prefixes/test_1" ] + [
13491349 test_bucket_name + f"/prefixes/test_{ cursor } " for cursor in range (10 , 20 )
13501350 ]
1351+
1352+
1353+ def test_expand_path (storage ):
1354+ test_bucket = "data"
1355+ test_dir = f"{ test_bucket } /testexpandpath"
1356+ sub_dir_1 = f"{ test_dir } /subdir1"
1357+ sub_dir_2 = f"{ sub_dir_1 } /subdir2"
1358+ test_blobs = [
1359+ f"{ test_dir } /blob1" ,
1360+ f"{ test_dir } /blob2" ,
1361+ f"{ test_dir } /subdir1/blob3" ,
1362+ f"{ test_dir } /subdir1/blob4" ,
1363+ f"{ test_dir } /subdir1/subdir2/blob5" ,
1364+ ]
1365+
1366+ expected_dirs_w_trailing_slash = test_blobs .copy ()
1367+ expected_dirs_w_trailing_slash .append (sub_dir_1 + "/" )
1368+ expected_dirs_w_trailing_slash .append (sub_dir_2 + "/" )
1369+
1370+ expected_dirs_wo_trailing_slash = test_blobs .copy ()
1371+ expected_dirs_wo_trailing_slash .append (sub_dir_1 )
1372+ expected_dirs_wo_trailing_slash .append (sub_dir_2 )
1373+
1374+ fs = AzureBlobFileSystem (
1375+ account_name = storage .account_name , connection_string = CONN_STR
1376+ )
1377+ for blob in test_blobs :
1378+ fs .touch (blob )
1379+
1380+ result_without_slash = fs .expand_path (test_dir , recursive = True )
1381+ assert sorted (result_without_slash ) == sorted (expected_dirs_w_trailing_slash )
1382+
1383+ result_with_slash = fs .expand_path (test_dir + "/" , recursive = True )
1384+ assert sorted (result_with_slash ) == sorted (expected_dirs_w_trailing_slash )
1385+
1386+ result_glob = fs .expand_path (test_dir + "/*" , recursive = True )
1387+ assert sorted (result_glob ) == sorted (expected_dirs_wo_trailing_slash )
0 commit comments