MCPcopy Index your code
hub / github.com/python/cpython / temp_cwd

Function temp_cwd

Lib/test/support/os_helper.py:583–599  ·  view source on GitHub ↗

Context manager that temporarily creates and changes the CWD. The function temporarily changes the current working directory after creating a temporary directory in the current directory with name *name*. If *name* is None, the temporary directory is created using tempfile.mkd

(name='tempcwd', quiet=False)

Source from the content-addressed store, hash-verified

581
582@contextlib.contextmanager
583def temp_cwd(name='tempcwd', quiet=False):
584 """
585 Context manager that temporarily creates and changes the CWD.
586
587 The function temporarily changes the current working directory
588 after creating a temporary directory in the current directory with
589 name *name*. If *name* is None, the temporary directory is
590 created using tempfile.mkdtemp.
591
592 If *quiet* is False (default) and it is not possible to
593 create or change the CWD, an error is raised. If *quiet* is True,
594 only a warning is raised and the original CWD is used.
595
596 """
597 with temp_dir(path=name, quiet=quiet) as temp_path:
598 with change_cwd(temp_path, quiet=quiet) as cwd_dir:
599 yield cwd_dir
600
601
602def create_empty_file(filename):

Callers 15

test_debug_in_fileMethod · 0.90
test_gh139516Method · 0.90
test_extractMethod · 0.90
test_extract_allMethod · 0.90
test_compilationMethod · 0.90
test_binary_headerMethod · 0.90
test_po_with_bomMethod · 0.90

Calls 2

temp_dirFunction · 0.85
change_cwdFunction · 0.85

Tested by 15

test_debug_in_fileMethod · 0.72
test_gh139516Method · 0.72
test_extractMethod · 0.72
test_extract_allMethod · 0.72
test_compilationMethod · 0.72
test_binary_headerMethod · 0.72
test_po_with_bomMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…