def METHOD_NAME(tmpdir):
    old_cwd = os.getcwd()
    try:
        level1 = tmpdir.mkdir("level1")
        level2 = level1.mkdir("level2")
        os.chdir(str(level2))
        assert os.path.split(os.getcwd())[-1] == "level2"
        # No directory
        with push_dir():
            os.chdir(os.path.join(os.getcwd(), ".."))
            assert os.path.split(os.getcwd())[-1] == "level1"
        assert os.path.split(os.getcwd())[-1] == "level2"
        # With existing directory
        with push_dir(directory=os.path.join(os.getcwd(), "..")):
            assert os.path.split(os.getcwd())[-1] == "level1"
        assert os.path.split(os.getcwd())[-1] == "level2"
        foo_directory = os.path.join(str(tmpdir), "foo")
        # With non existing directory
        failed = False
        try:
            with push_dir(directory=foo_directory):
                pass
        except OSError:
            failed = True
        assert failed
        assert not os.path.isdir(foo_directory)
        # With make_directory option
        with push_dir(directory=foo_directory, make_directory=True):
            assert os.getcwd() == foo_directory
        assert os.path.split(os.getcwd())[-1] == "level2"
        assert os.path.isdir(foo_directory)
    finally:
        os.chdir(old_cwd)