@contextmanager<EOL>def pushd(path):
saved = os.getcwd()<EOL>os.chdir(path)<EOL>try:<EOL><INDENT>yield saved<EOL><DEDENT>finally:<EOL><INDENT>os.chdir(saved)<EOL><DEDENT>
A context that enters a given directory and restores the old state on exit.

        The original directory is returned as the context variable.