MCPcopy
hub / github.com/encode/uvicorn / as_cwd

Function as_cwd

tests/utils.py:41–48  ·  view source on GitHub ↗

Changes working directory and returns to previous on exit.

(path: Path)

Source from the content-addressed store, hash-verified

39
40@contextmanager
41def as_cwd(path: Path):
42 """Changes working directory and returns to previous on exit."""
43 prev_cwd = Path.cwd()
44 os.chdir(path)
45 try:
46 yield
47 finally:
48 os.chdir(prev_cwd)
49
50
51def get_asyncio_default_loop_per_os() -> type[asyncio.AbstractEventLoop]:

Calls

no outgoing calls