@@ -282,24 +282,34 @@ def mkdirs(path):
282
282
@pytest .fixture
283
283
def fs (request , s3_fs , az_fs , az_dsn_fs , https_fs , gcs_fs ):
284
284
uri , path_to , read , write , mkdirs , join , internal = [None ] * NUM_ATR_FS
285
- should_skip (request .param , check_only = False )
285
+ test_fs_uri = request .param
286
+ should_skip (test_fs_uri , check_only = False )
286
287
287
- if request . param == S3_URI :
288
+ if test_fs_uri == S3_URI :
288
289
uri , path_to , read , write , mkdirs , join , internal = s3_fs
289
- elif request . param == AZ_URI :
290
+ elif test_fs_uri == AZ_URI :
290
291
uri , path_to , read , write , mkdirs , join , internal = az_fs
291
- elif request . param == AZ_DSN_URI :
292
+ elif test_fs_uri == AZ_DSN_URI :
292
293
uri , path_to , read , write , mkdirs , join , internal = az_dsn_fs
293
- elif request . param == HTTPS_URI :
294
+ elif test_fs_uri == HTTPS_URI :
294
295
uri , path_to , read , write , mkdirs , join , internal = https_fs
295
- elif request . param == GCS_URI :
296
+ elif test_fs_uri == GCS_URI :
296
297
uri , path_to , read , write , mkdirs , join , internal = gcs_fs
297
298
298
- path_to_rand = functools .partial (path_to , str (random .getrandbits (32 )))
299
- mkdirs (path_to_rand ("" ))
299
+ path_to_rand = None
300
+ test_patchs = request .getfixturevalue ("patchs" )
301
+ if (test_fs_uri , test_patchs ) in fs .path_to_rand_cache :
302
+ path_to_rand = fs .path_to_rand_cache [(test_fs_uri , test_patchs )]
303
+ else :
304
+ path_to_rand = functools .partial (path_to , str (random .getrandbits (32 )))
305
+ mkdirs (path_to_rand ("" ))
306
+ fs .path_to_rand_cache [(test_fs_uri , test_patchs )] = path_to_rand
300
307
yield uri , path_to_rand , read , write , mkdirs , join , internal
301
308
302
309
310
+ fs .path_to_rand_cache = {}
311
+
312
+
303
313
@pytest .mark .parametrize (
304
314
"fs, patchs" ,
305
315
[(S3_URI , None ), (AZ_URI , None ), (AZ_DSN_URI , None ), (GCS_URI , None )],
0 commit comments