def test_uncpushd_push_to_same_share(xonsh_builtins): xonsh_builtins.__xonsh_env__ = Env(CDPATH=PARENT, PWD=HERE) dirstack.cd([PARENT]) owd = os.getcwd() assert owd.casefold() == xonsh_builtins.__xonsh_env__['PWD'].casefold() dirstack.pushd([r'\\localhost\uncpushd_test_HERE']) wd = os.getcwd() assert os.path.splitdrive(wd)[0].casefold() == TEMP_DRIVE[0] assert os.path.splitdrive(wd)[1].casefold() == '\\' assert len(_unc_tempDrives) == 1 assert len(DIRSTACK) == 1 dirstack.pushd([r'\\localhost\uncpushd_test_HERE']) wd = os.getcwd() assert os.path.splitdrive(wd)[0].casefold() == TEMP_DRIVE[0] assert os.path.splitdrive(wd)[1].casefold() == '\\' assert len(_unc_tempDrives) == 1 assert len(DIRSTACK) == 2 dirstack.popd([]) assert os.path.isdir(TEMP_DRIVE[0] + '\\'), "Temp drived not unmapped till last reference removed" dirstack.popd([]) assert owd.casefold() == os.getcwd().casefold(), "popd returned cwd to expected dir" assert len(_unc_tempDrives) == 0
def test_uncpushd_push_to_same_share(xession, shares_setup): if shares_setup is None: return xession.env = Env(CDPATH=PARENT, PWD=HERE) dirstack.cd([PARENT]) owd = os.getcwd() assert owd.casefold() == xession.env["PWD"].casefold() dirstack.pushd([r"\\localhost\uncpushd_test_HERE"]) wd = os.getcwd() assert os.path.splitdrive(wd)[0].casefold() == TEMP_DRIVE[0] assert os.path.splitdrive(wd)[1].casefold() == "\\" assert len(_unc_tempDrives) == 1 assert len(DIRSTACK) == 1 dirstack.pushd([r"\\localhost\uncpushd_test_HERE"]) wd = os.getcwd() assert os.path.splitdrive(wd)[0].casefold() == TEMP_DRIVE[0] assert os.path.splitdrive(wd)[1].casefold() == "\\" assert len(_unc_tempDrives) == 1 assert len(DIRSTACK) == 2 dirstack.popd([]) assert os.path.isdir( TEMP_DRIVE[0] + "\\" ), "Temp drive not unmapped till last reference removed" dirstack.popd([]) assert owd.casefold() == os.getcwd().casefold(), "popd returned cwd to expected dir" assert len(_unc_tempDrives) == 0
def test_uncpushd_push_to_same_share(xonsh_builtins, shares_setup): if shares_setup is None: return xonsh_builtins.__xonsh_env__ = Env(CDPATH=PARENT, PWD=HERE) dirstack.cd([PARENT]) owd = os.getcwd() assert owd.casefold() == xonsh_builtins.__xonsh_env__['PWD'].casefold() dirstack.pushd([r'\\localhost\uncpushd_test_HERE']) wd = os.getcwd() assert os.path.splitdrive(wd)[0].casefold() == TEMP_DRIVE[0] assert os.path.splitdrive(wd)[1].casefold() == '\\' assert len(_unc_tempDrives) == 1 assert len(DIRSTACK) == 1 dirstack.pushd([r'\\localhost\uncpushd_test_HERE']) wd = os.getcwd() assert os.path.splitdrive(wd)[0].casefold() == TEMP_DRIVE[0] assert os.path.splitdrive(wd)[1].casefold() == '\\' assert len(_unc_tempDrives) == 1 assert len(DIRSTACK) == 2 dirstack.popd([]) assert os.path.isdir( TEMP_DRIVE[0] + '\\'), "Temp drive not unmapped till last reference removed" dirstack.popd([]) assert owd.casefold() == os.getcwd().casefold( ), "popd returned cwd to expected dir" assert len(_unc_tempDrives) == 0
def test_simple(): load_builtins() with xonsh_env(Env(CDPATH=PARENT, PWD=PARENT)): with chdir(PARENT): assert os.getcwd() != HERE dirstack.cd(["tests"]) assert os.getcwd() == HERE
def test_simple(): load_builtins() with xonsh_env(Env(CDPATH=PARENT, PWD=PARENT)): with chdir(PARENT): assert_not_equal(os.getcwd(), HERE) dirstack.cd(["tests"]) assert_equal(os.getcwd(), HERE)
def test_uncpushd_push_to_same_share(xonsh_builtins, shares_setup): if shares_setup is None: return xonsh_builtins.__xonsh__.env = Env(CDPATH=PARENT, PWD=HERE) dirstack.cd([PARENT]) owd = os.getcwd() assert owd.casefold() == xonsh_builtins.__xonsh__.env["PWD"].casefold() dirstack.pushd([r"\\localhost\uncpushd_test_HERE"]) wd = os.getcwd() assert os.path.splitdrive(wd)[0].casefold() == TEMP_DRIVE[0] assert os.path.splitdrive(wd)[1].casefold() == "\\" assert len(_unc_tempDrives) == 1 assert len(DIRSTACK) == 1 dirstack.pushd([r"\\localhost\uncpushd_test_HERE"]) wd = os.getcwd() assert os.path.splitdrive(wd)[0].casefold() == TEMP_DRIVE[0] assert os.path.splitdrive(wd)[1].casefold() == "\\" assert len(_unc_tempDrives) == 1 assert len(DIRSTACK) == 2 dirstack.popd([]) assert os.path.isdir( TEMP_DRIVE[0] + "\\" ), "Temp drive not unmapped till last reference removed" dirstack.popd([]) assert owd.casefold() == os.getcwd().casefold(), "popd returned cwd to expected dir" assert len(_unc_tempDrives) == 0
def test_cdpath_collision(xession): xession.env.update(dict(CDPATH=PARENT, PWD=HERE)) sub_tests = os.path.join(HERE, "tests") if not os.path.exists(sub_tests): os.mkdir(sub_tests) with chdir(HERE): assert os.getcwd() == HERE dirstack.cd(["tests"]) assert os.getcwd() == os.path.join(HERE, "tests")
def test_cdpath_collision(): with xonsh_env(Env(CDPATH=PARENT, PWD=HERE)): sub_tests = os.path.join(HERE, "tests") if not os.path.exists(sub_tests): os.mkdir(sub_tests) with chdir(HERE): assert os.getcwd() == HERE dirstack.cd(["tests"]) assert os.getcwd() == os.path.join(HERE, "tests")
def test_cdpath_collision(): with xonsh_env(Env(CDPATH=PARENT)): sub_tests = os.path.join(HERE, "tests") if not os.path.exists(sub_tests): os.mkdir(sub_tests) with chdir(HERE): assert_equal(os.getcwd(), HERE) dirstack.cd(["tests"]) assert_equal(os.getcwd(), os.path.join(HERE, "tests"))
def test_cdpath_collision(xonsh_builtins): xonsh_builtins.__xonsh_env__ = Env(CDPATH=PARENT, PWD=HERE) sub_tests = os.path.join(HERE, "tests") if not os.path.exists(sub_tests): os.mkdir(sub_tests) with chdir(HERE): assert os.getcwd() == HERE dirstack.cd(["tests"]) assert os.getcwd() == os.path.join(HERE, "tests")
def ghq(event): cands = run_subproc([['ghq', 'list']], captured='stdout').strip().split('\n') result, _ = select(map(lambda s: s.encode(), reversed(cands)), options=["--layout=bottom-up"]) if len(result) > 0: root = run_subproc([["ghq", 'root']], captured="stdout") path = os.path.join(root.strip(), result.decode().strip()) dirstack.cd([path]) event.current_buffer.validate_and_handle() # refresh prompt
def test_pushdpopd(xession): """Simple non-UNC push/pop to verify we didn't break nonUNC case.""" xession.env = Env(CDPATH=PARENT, PWD=HERE) dirstack.cd([PARENT]) owd = os.getcwd() assert owd.casefold() == xession.env["PWD"].casefold() dirstack.pushd([HERE]) wd = os.getcwd() assert wd.casefold() == HERE.casefold() dirstack.popd([]) assert owd.casefold() == os.getcwd().casefold(), "popd returned cwd to expected dir"
def test_pushdpopd(xonsh_builtins): """Simple non-UNC push/pop to verify we didn't break nonUNC case. """ xonsh_builtins.__xonsh_env__ = Env(CDPATH=PARENT, PWD=HERE) dirstack.cd([PARENT]) owd = os.getcwd() assert owd.casefold() == xonsh_builtins.__xonsh_env__['PWD'].casefold() dirstack.pushd([HERE]) wd = os.getcwd() assert wd.casefold() == HERE.casefold() dirstack.popd([]) assert owd.casefold() == os.getcwd().casefold(), "popd returned cwd to expected dir"
def test_uncpushd_simple_push_pop(xonsh_builtins, shares_setup): xonsh_builtins.__xonsh_env__ = Env(CDPATH=PARENT, PWD=HERE) dirstack.cd([PARENT]) owd = os.getcwd() assert owd.casefold() == xonsh_builtins.__xonsh_env__['PWD'].casefold() dirstack.pushd([r'\\localhost\uncpushd_test_HERE']) wd = os.getcwd() assert os.path.splitdrive(wd)[0].casefold() == TEMP_DRIVE[0] assert os.path.splitdrive(wd)[1].casefold() == '\\' dirstack.popd([]) assert owd.casefold() == os.getcwd().casefold(), "popd returned cwd to expected dir" assert len(_unc_tempDrives) == 0
def test_uncpushd_simple_push_pop(xession, shares_setup): if shares_setup is None: return xession.env = Env(CDPATH=PARENT, PWD=HERE) dirstack.cd([PARENT]) owd = os.getcwd() assert owd.casefold() == xession.env["PWD"].casefold() dirstack.pushd([r"\\localhost\uncpushd_test_HERE"]) wd = os.getcwd() assert os.path.splitdrive(wd)[0].casefold() == TEMP_DRIVE[0] assert os.path.splitdrive(wd)[1].casefold() == "\\" dirstack.popd([]) assert owd.casefold() == os.getcwd().casefold(), "popd returned cwd to expected dir" assert len(_unc_tempDrives) == 0
def test_uncpushd_simple_push_pop(xonsh_builtins, shares_setup): xonsh_builtins.__xonsh_env__ = Env(CDPATH=PARENT, PWD=HERE) dirstack.cd([PARENT]) owd = os.getcwd() assert owd.casefold() == xonsh_builtins.__xonsh_env__['PWD'].casefold() dirstack.pushd([r'\\localhost\uncpushd_test_HERE']) wd = os.getcwd() assert os.path.splitdrive(wd)[0].casefold() == 'z:' assert os.path.splitdrive(wd)[1].casefold() == '\\' dirstack.popd([]) assert owd.casefold() == os.getcwd().casefold( ), "popd returned cwd to expected dir" assert len(_unc_tempDrives) == 0
def test_uncpushd_cd_unc_auto_pushd(xonsh_builtins_cd, with_unc_check_enabled): xonsh_builtins_cd.__xonsh_env__['AUTO_PUSHD'] = True so, se, rc = dirstack.cd([r'\\localhost\uncpushd_test_PARENT']) assert rc == 0 assert os.getcwd().casefold() == TEMP_DRIVE[0] + '\\' assert len(DIRSTACK) == 1 assert os.path.isdir(TEMP_DRIVE[0] + '\\')
def test_uncpushd_cd_unc_no_auto_pushd(xonsh_builtins_cd, with_unc_check_enabled): if with_unc_check_enabled == 0: return so, se, rc = dirstack.cd([r"\\localhost\uncpushd_test_PARENT"]) assert rc != 0 assert so is None or len(so) == 0 assert "disableunccheck" in se.casefold() and "auto_pushd" in se.casefold()
def test_uncpushd_cd_unc_auto_pushd(xonsh_builtins_cd, with_unc_check_enabled): xonsh_builtins_cd.__xonsh_env__['AUTO_PUSHD'] = True so, se, rc = dirstack.cd([r'\\localhost\uncpushd_test_PARENT']) assert rc == 0 assert os.getcwd().casefold() == 'z:\\' assert len(DIRSTACK) == 1 assert os.path.isdir('z:\\')
def test_uncpushd_cd_unc_no_auto_pushd(xonsh_builtins_cd, with_unc_check_enabled): if with_unc_check_enabled == 0: return so, se, rc = dirstack.cd([r'\\localhost\uncpushd_test_PARENT']) assert rc != 0 assert so is None or len(so) == 0 assert 'disableunccheck' in se.casefold() and 'auto_pushd' in se.casefold()
def test_uncpushd_cd_unc_auto_pushd(xonsh_builtins_cd, with_unc_check_enabled): xonsh_builtins_cd.env["AUTO_PUSHD"] = True so, se, rc = dirstack.cd([r"\\localhost\uncpushd_test_PARENT"]) if rc != 0: return assert os.getcwd().casefold() == TEMP_DRIVE[0] + "\\" assert len(DIRSTACK) == 1 assert os.path.isdir(TEMP_DRIVE[0] + "\\")
def test_uncpushd_push_other_push_same(xession, shares_setup): """push to a, then to b. verify drive letter is TEMP_DRIVE[2], skipping already used TEMP_DRIVE[1] Then push to a again. Pop (check b unmapped and a still mapped), pop, pop (check a is unmapped)""" if shares_setup is None: return xession.env.update(dict(CDPATH=PARENT, PWD=HERE)) dirstack.cd([PARENT]) owd = os.getcwd() assert owd.casefold() == xession.env["PWD"].casefold() dirstack.pushd([r"\\localhost\uncpushd_test_HERE"]) assert os.getcwd().casefold() == TEMP_DRIVE[0] + "\\" assert len(_unc_tempDrives) == 1 assert len(DIRSTACK) == 1 dirstack.pushd([r"\\localhost\uncpushd_test_PARENT"]) os.getcwd() assert os.getcwd().casefold() == TEMP_DRIVE[2] + "\\" assert len(_unc_tempDrives) == 2 assert len(DIRSTACK) == 2 dirstack.pushd([r"\\localhost\uncpushd_test_HERE"]) assert os.getcwd().casefold() == TEMP_DRIVE[0] + "\\" assert len(_unc_tempDrives) == 2 assert len(DIRSTACK) == 3 dirstack.popd([]) assert os.getcwd().casefold() == TEMP_DRIVE[2] + "\\" assert len(_unc_tempDrives) == 2 assert len(DIRSTACK) == 2 assert os.path.isdir(TEMP_DRIVE[2] + "\\") assert os.path.isdir(TEMP_DRIVE[0] + "\\") dirstack.popd([]) assert os.getcwd().casefold() == TEMP_DRIVE[0] + "\\" assert len(_unc_tempDrives) == 1 assert len(DIRSTACK) == 1 assert not os.path.isdir(TEMP_DRIVE[2] + "\\") assert os.path.isdir(TEMP_DRIVE[0] + "\\") dirstack.popd([]) assert os.getcwd().casefold() == owd.casefold() assert len(_unc_tempDrives) == 0 assert len(DIRSTACK) == 0 assert not os.path.isdir(TEMP_DRIVE[2] + "\\") assert not os.path.isdir(TEMP_DRIVE[0] + "\\")
def test_uncpushd_cd_unc_auto_pushd(xonsh_builtins_cd, with_unc_check_enabled): xonsh_builtins_cd.__xonsh__.env["AUTO_PUSHD"] = True so, se, rc = dirstack.cd([r"\\localhost\uncpushd_test_PARENT"]) if rc != 0: return assert os.getcwd().casefold() == TEMP_DRIVE[0] + "\\" assert len(DIRSTACK) == 1 assert os.path.isdir(TEMP_DRIVE[0] + "\\")
def test_uncpushd_push_other_push_same(xonsh_builtins, shares_setup): """push to a, then to b. verify drive letter is TEMP_DRIVE[2], skipping already used TEMP_DRIVE[1] Then push to a again. Pop (check b unmapped and a still mapped), pop, pop (check a is unmapped)""" if shares_setup is None: return xonsh_builtins.__xonsh_env__ = Env(CDPATH=PARENT, PWD=HERE) dirstack.cd([PARENT]) owd = os.getcwd() assert owd.casefold() == xonsh_builtins.__xonsh_env__['PWD'].casefold() dirstack.pushd([r'\\localhost\uncpushd_test_HERE']) assert os.getcwd().casefold() == TEMP_DRIVE[0] + '\\' assert len(_unc_tempDrives) == 1 assert len(DIRSTACK) == 1 dirstack.pushd([r'\\localhost\uncpushd_test_PARENT']) wd = os.getcwd() assert os.getcwd().casefold() == TEMP_DRIVE[2] + '\\' assert len(_unc_tempDrives) == 2 assert len(DIRSTACK) == 2 dirstack.pushd([r'\\localhost\uncpushd_test_HERE']) assert os.getcwd().casefold() == TEMP_DRIVE[0] + '\\' assert len(_unc_tempDrives) == 2 assert len(DIRSTACK) == 3 dirstack.popd([]) assert os.getcwd().casefold() == TEMP_DRIVE[2] + '\\' assert len(_unc_tempDrives) == 2 assert len(DIRSTACK) == 2 assert os.path.isdir(TEMP_DRIVE[2] + '\\') assert os.path.isdir(TEMP_DRIVE[0] + '\\') dirstack.popd([]) assert os.getcwd().casefold() == TEMP_DRIVE[0] + '\\' assert len(_unc_tempDrives) == 1 assert len(DIRSTACK) == 1 assert not os.path.isdir(TEMP_DRIVE[2] + '\\') assert os.path.isdir(TEMP_DRIVE[0] + '\\') dirstack.popd([]) assert os.getcwd().casefold() == owd.casefold() assert len(_unc_tempDrives) == 0 assert len(DIRSTACK) == 0 assert not os.path.isdir(TEMP_DRIVE[2] + '\\') assert not os.path.isdir(TEMP_DRIVE[0] + '\\')
def test_uncpushd_push_other_push_same(xonsh_builtins): """push to a, then to b. verify is w:, skipping already used y: Then push to a again. Pop (check b unmapped and a still mapped), pop, pop (check a is unmapped)""" xonsh_builtins.__xonsh_env__ = Env(CDPATH=PARENT, PWD=HERE) dirstack.cd([PARENT]) owd = os.getcwd() assert owd.casefold() == xonsh_builtins.__xonsh_env__['PWD'].casefold() dirstack.pushd([r'\\localhost\uncpushd_test_HERE']) assert os.getcwd().casefold() == 'z:\\' assert len(_unc_tempDrives) == 1 assert len(DIRSTACK) == 1 dirstack.pushd([r'\\localhost\uncpushd_test_PARENT']) wd = os.getcwd() assert os.getcwd().casefold() == 'x:\\' assert len(_unc_tempDrives) == 2 assert len(DIRSTACK) == 2 dirstack.pushd([r'\\localhost\uncpushd_test_HERE']) assert os.getcwd().casefold() == 'z:\\' assert len(_unc_tempDrives) == 2 assert len(DIRSTACK) == 3 dirstack.popd([]) assert os.getcwd().casefold() == 'x:\\' assert len(_unc_tempDrives) == 2 assert len(DIRSTACK) == 2 assert os.path.isdir('x:\\') assert os.path.isdir('z:\\') dirstack.popd([]) assert os.getcwd().casefold() == 'z:\\' assert len(_unc_tempDrives) == 1 assert len(DIRSTACK) == 1 assert not os.path.isdir('x:\\') assert os.path.isdir('z:\\') dirstack.popd([]) assert os.getcwd().casefold() == owd.casefold() assert len(_unc_tempDrives) == 0 assert len(DIRSTACK) == 0 assert not os.path.isdir('x:\\') assert not os.path.isdir('z:\\')
def test_cdpath_events(xonsh_builtins, tmpdir): xonsh_builtins.__xonsh_env__ = Env(CDPATH=PARENT, PWD=os.getcwd()) target = str(tmpdir) ev = None @xonsh_builtins.events.on_chdir def handler(old, new): nonlocal ev ev = old, new old_dir = os.getcwd() try: dirstack.cd([target]) except: raise else: assert (old_dir, target) == ev finally: # Use os.chdir() here so dirstack.cd() doesn't fire events (or fail again) os.chdir(old_dir)
def test_cdpath_events(xonsh_builtins, tmpdir): xonsh_builtins.__xonsh_env__ = Env(CDPATH=PARENT, PWD=os.getcwd()) target = str(tmpdir) ev = None @xonsh_builtins.events.on_chdir def handler(olddir, newdir, **kw): nonlocal ev ev = olddir, newdir old_dir = os.getcwd() try: dirstack.cd([target]) except: raise else: assert (old_dir, target) == ev finally: # Use os.chdir() here so dirstack.cd() doesn't fire events (or fail again) os.chdir(old_dir)
def test_cd_autopush(xession, tmpdir): xession.env = Env(CDPATH=PARENT, PWD=os.getcwd(), AUTO_PUSHD=True) target = str(tmpdir) old_dir = os.getcwd() old_ds_size = len(dirstack.DIRSTACK) assert target != old_dir try: dirstack.cd([target]) assert target == os.getcwd() assert old_ds_size + 1 == len(dirstack.DIRSTACK) dirstack.popd([]) except Exception: raise finally: while len(dirstack.DIRSTACK) > old_ds_size: dirstack.popd([]) assert old_dir == os.getcwd()
def test_cd_autopush(xonsh_builtins, tmpdir): xonsh_builtins.__xonsh_env__ = Env(CDPATH=PARENT, PWD=os.getcwd(), AUTO_PUSHD=True) target = str(tmpdir) old_dir = os.getcwd() old_ds_size = len(dirstack.DIRSTACK) assert target != old_dir try: dirstack.cd([target]) assert target == os.getcwd() assert old_ds_size + 1 == len(dirstack.DIRSTACK) dirstack.popd([]) except: raise finally: while len(dirstack.DIRSTACK) > old_ds_size: dirstack.popd([]) assert old_dir == os.getcwd()
def test_cdpath_events(xession, tmpdir): xession.env.update(dict(CDPATH=PARENT, PWD=os.getcwd())) target = str(tmpdir) ev = None @xession.builtins.events.on_chdir def handler(olddir, newdir, **kw): nonlocal ev ev = olddir, newdir old_dir = os.getcwd() try: dirstack.cd([target]) except Exception: raise else: assert (old_dir, target) == ev finally: # Use os.chdir() here so dirstack.cd() doesn't fire events (or fail again) os.chdir(old_dir)
def test_cdpath_simple(): with xonsh_env(Env(CDPATH=PARENT, PWD=HERE)): with chdir(os.path.normpath("/")): assert os.getcwd() != HERE dirstack.cd(["tests"]) assert os.getcwd() == HERE
def test_cdpath_simple(xonsh_builtins): xonsh_builtins.__xonsh_env__ = Env(CDPATH=PARENT, PWD=HERE) with chdir(os.path.normpath("/")): assert os.getcwd() != HERE dirstack.cd(["tests"]) assert os.getcwd() == HERE
def test_cdpath_simple(xession): xession.env = Env(CDPATH=PARENT, PWD=HERE) with chdir(os.path.normpath("/")): assert os.getcwd() != HERE dirstack.cd(["tests"]) assert os.getcwd() == HERE
def test_uncpushd_cd_unc_nocheck(xonsh_builtins_cd, with_unc_check_disabled): if with_unc_check_disabled == 0: return dirstack.cd([r"\\localhost\uncpushd_test_HERE"]) assert os.getcwd().casefold() == r"\\localhost\uncpushd_test_here"
def test_uncpushd_cd_unc_nocheck(xonsh_builtins_cd, with_unc_check_disabled): if with_unc_check_disabled == 0: return dirstack.cd([r'\\localhost\uncpushd_test_HERE']) assert os.getcwd().casefold() == r'\\localhost\uncpushd_test_here'
def test_uncpushd_cd_unc_nocheck(xonsh_builtins_cd, with_unc_check_disabled): dirstack.cd([r'\\localhost\uncpushd_test_HERE']) assert os.getcwd().casefold() == r'\\localhost\uncpushd_test_here'
def test_cd_dot(xonsh_builtins): xonsh_builtins.__xonsh_env__ = Env(PWD=os.getcwd()) owd = os.getcwd().casefold() dirstack.cd(['.']) assert owd == os.getcwd().casefold()
def go_up(event): dirstack.cd([os.path.dirname(__xonsh__.env['PWD'])]) event.current_buffer.validate_and_handle()
def test_simple(xession): xession.env = Env(CDPATH=PARENT, PWD=PARENT) with chdir(PARENT): assert os.getcwd() != HERE dirstack.cd(["tests"]) assert os.getcwd() == HERE
def test_simple(): load_builtins() with chdir(PARENT): assert_not_equal(os.getcwd(), HERE) dirstack.cd(["tests"]) assert_equal(os.getcwd(), HERE)
def test_cdpath_simple(): with xonsh_env(Env(CDPATH=PARENT)): with chdir(os.path.normpath("/")): assert_not_equal(os.getcwd(), HERE) dirstack.cd(["tests"]) assert_equal(os.getcwd(), HERE)
def test_simple(xonsh_builtins): xonsh_builtins.__xonsh_env__ = Env(CDPATH=PARENT, PWD=PARENT) with chdir(PARENT): assert os.getcwd() != HERE dirstack.cd(["tests"]) assert os.getcwd() == HERE
def test_cd_dot(xession): xession.env = Env(PWD=os.getcwd()) owd = os.getcwd().casefold() dirstack.cd(["."]) assert owd == os.getcwd().casefold()