@@ -1348,3 +1348,41 @@ 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 (test_dir )
1368+ expected_dirs_w_trailing_slash .append (sub_dir_1 + "/" )
1369+ expected_dirs_w_trailing_slash .append (sub_dir_2 + "/" )
1370+
1371+ expected_dirs_wo_trailing_slash = test_blobs .copy ()
1372+ expected_dirs_wo_trailing_slash .append (sub_dir_1 )
1373+ expected_dirs_wo_trailing_slash .append (sub_dir_2 )
1374+
1375+ fs = AzureBlobFileSystem (
1376+ account_name = storage .account_name , connection_string = CONN_STR
1377+ )
1378+ for blob in test_blobs :
1379+ fs .touch (blob )
1380+
1381+ result_without_slash = fs .expand_path (test_dir , recursive = True )
1382+ assert sorted (result_without_slash ) == sorted (expected_dirs_w_trailing_slash )
1383+
1384+ result_with_slash = fs .expand_path (test_dir + "/" , recursive = True )
1385+ assert sorted (result_with_slash ) == sorted (expected_dirs_w_trailing_slash )
1386+
1387+ result_glob = fs .expand_path (test_dir + "/*" , recursive = True )
1388+ assert sorted (result_glob ) == sorted (expected_dirs_wo_trailing_slash )
0 commit comments