aboutsummaryrefslogtreecommitdiffstats
path: root/tests/utils.py
blob: 202cea548824a4d15a3086911fe142631b2f4fbe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import contextlib
import os
import io
import pathlib
from typing import Iterator


@contextlib.contextmanager
def as_cwd(path: pathlib.Path) -> Iterator[pathlib.Path]:
    old_cwd = os.getcwd()
    os.chdir(path)
    try:
        yield path
    finally:
        os.chdir(old_cwd)