Skip to content

Commit 17fc1bf

Browse files
committed
filesystem with the same config should share the same random prefix
1 parent 1a36c90 commit 17fc1bf

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

tests/test_filesystem.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -282,24 +282,34 @@ def mkdirs(path):
282282
@pytest.fixture
283283
def fs(request, s3_fs, az_fs, az_dsn_fs, https_fs, gcs_fs):
284284
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)
286287

287-
if request.param == S3_URI:
288+
if test_fs_uri == S3_URI:
288289
uri, path_to, read, write, mkdirs, join, internal = s3_fs
289-
elif request.param == AZ_URI:
290+
elif test_fs_uri == AZ_URI:
290291
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:
292293
uri, path_to, read, write, mkdirs, join, internal = az_dsn_fs
293-
elif request.param == HTTPS_URI:
294+
elif test_fs_uri == HTTPS_URI:
294295
uri, path_to, read, write, mkdirs, join, internal = https_fs
295-
elif request.param == GCS_URI:
296+
elif test_fs_uri == GCS_URI:
296297
uri, path_to, read, write, mkdirs, join, internal = gcs_fs
297298

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
300307
yield uri, path_to_rand, read, write, mkdirs, join, internal
301308

302309

310+
fs.path_to_rand_cache = {}
311+
312+
303313
@pytest.mark.parametrize(
304314
"fs, patchs",
305315
[(S3_URI, None), (AZ_URI, None), (AZ_DSN_URI, None), (GCS_URI, None)],

0 commit comments

Comments
 (0)