Path 1: 45 calls (0.94)

PosixPath (32) '/Users/andrehora/Documents/git/projects-pathspotter/pylint/tests' (12) '/Users/andrehora/Documents/git/projects-pathspotter/pylint/tes...

None (45)

1@contextlib.contextmanager
2def _test_cwd(
3    current_working_directory: str | Path | None = None,
4) -> Generator[None, None, None]:
5    original_dir = os.getcwd()
6    try:
7        if current_working_directory is not None:
8            os.chdir(current_working_directory)
9        yield
10    finally:
11        os.chdir(original_dir)
            

Path 2: 3 calls (0.06)

None (3)

None (3)

1@contextlib.contextmanager
2def _test_cwd(
3    current_working_directory: str | Path | None = None,
4) -> Generator[None, None, None]:
5    original_dir = os.getcwd()
6    try:
7        if current_working_directory is not None:
8            os.chdir(current_working_directory)
9        yield
10    finally:
11        os.chdir(original_dir)