def test_cwd_snapshot(pytester: Pytester) -> None: foo = pytester.mkdir("foo") bar = pytester.mkdir("bar") os.chdir(foo) snapshot = CwdSnapshot() os.chdir(bar) assert Path().absolute() == bar snapshot.restore() assert Path().absolute() == foo
def test_cwd_snapshot(tmpdir): foo = tmpdir.ensure("foo", dir=1) bar = tmpdir.ensure("bar", dir=1) foo.chdir() snapshot = CwdSnapshot() bar.chdir() assert py.path.local() == bar snapshot.restore() assert py.path.local() == foo