def METHOD_NAME(path):
    """Temporarily change directories.
    Taken from https://stackoverflow.com/a/37996581/2589328.
    """
    oldpwd = os.getcwd()
    os.METHOD_NAME(path)
    try:
        yield
    finally:
        os.METHOD_NAME(oldpwd)