MCPcopy Index your code
hub / github.com/RustPython/RustPython / get_work_dir

Function get_work_dir

Lib/test/libregrtest/utils.py:448–465  ·  view source on GitHub ↗
(parent_dir: StrPath, worker: bool = False)

Source from the content-addressed store, hash-verified

446
447
448def get_work_dir(parent_dir: StrPath, worker: bool = False) -> StrPath:
449 # Define a writable temp dir that will be used as cwd while running
450 # the tests. The name of the dir includes the pid to allow parallel
451 # testing (see the -j option).
452 # Emscripten and WASI have stubbed getpid(), Emscripten has only
453 # millisecond clock resolution. Use randint() instead.
454 if support.is_emscripten or support.is_wasi:
455 nounce = random.randint(0, 1_000_000)
456 else:
457 nounce = os.getpid()
458
459 if worker:
460 work_dir = WORK_DIR_PREFIX + str(nounce)
461 else:
462 work_dir = WORKER_WORK_DIR_PREFIX + str(nounce)
463 work_dir += os_helper.FS_NONASCII
464 work_dir = os.path.join(parent_dir, work_dir)
465 return work_dir
466
467
468@contextlib.contextmanager

Callers 2

run_testsMethod · 0.85
mainFunction · 0.85

Calls 3

strFunction · 0.85
randintMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected