mirror of
https://github.com/datahub-project/datahub.git
synced 2025-07-04 07:34:44 +00:00
16 lines
271 B
Python
16 lines
271 B
Python
import contextlib
|
|
import os
|
|
import pathlib
|
|
from typing import Iterator
|
|
|
|
|
|
@contextlib.contextmanager
|
|
def isolated_filesystem(temp_dir: pathlib.Path) -> Iterator[None]:
|
|
cwd = os.getcwd()
|
|
|
|
os.chdir(temp_dir)
|
|
try:
|
|
yield
|
|
finally:
|
|
os.chdir(cwd)
|