コード例 #1
0
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
コード例 #2
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
コード例 #3
0
ファイル: test_dirstack_unc.py プロジェクト: zzp0/xonsh
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
コード例 #4
0
ファイル: test_dirstack.py プロジェクト: BlaXpirit/xonsh
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
コード例 #5
0
ファイル: test_dirstack.py プロジェクト: zbrdge/xonsh
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)
コード例 #6
0
ファイル: test_dirstack_unc.py プロジェクト: mitnk/xonsh
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
コード例 #7
0
ファイル: test_dirstack.py プロジェクト: sthagen/xonsh
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")
コード例 #8
0
ファイル: test_dirstack.py プロジェクト: BlaXpirit/xonsh
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")
コード例 #9
0
ファイル: test_dirstack.py プロジェクト: semyon-san/xonsh
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"))
コード例 #10
0
ファイル: test_dirstack.py プロジェクト: barry-scott/xonsh
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")
コード例 #11
0
ファイル: selector.py プロジェクト: philopon/.xonsh
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
コード例 #12
0
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"
コード例 #13
0
ファイル: test_dirstack_unc.py プロジェクト: vermuz/xonsh
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"
コード例 #14
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() == 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
コード例 #15
0
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"
コード例 #16
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
コード例 #17
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
コード例 #18
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] + '\\')
コード例 #19
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()
コード例 #20
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() == 'z:\\'
    assert len(DIRSTACK) == 1
    assert os.path.isdir('z:\\')
コード例 #21
0
ファイル: test_dirstack_unc.py プロジェクト: janschulz/xonsh
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()
コード例 #22
0
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] + "\\")
コード例 #23
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] + "\\")
コード例 #24
0
ファイル: test_dirstack_unc.py プロジェクト: mitnk/xonsh
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] + "\\")
コード例 #25
0
ファイル: test_dirstack_unc.py プロジェクト: janschulz/xonsh
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] + '\\')
コード例 #26
0
ファイル: test_dirstack_unc.py プロジェクト: zzp0/xonsh
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] + '\\')
コード例 #27
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:\\')
コード例 #28
0
ファイル: test_dirstack.py プロジェクト: astronouth7303/xonsh
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)
コード例 #29
0
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)
コード例 #30
0
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()
コード例 #31
0
ファイル: test_dirstack.py プロジェクト: astronouth7303/xonsh
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()
コード例 #32
0
ファイル: test_dirstack.py プロジェクト: sthagen/xonsh
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)
コード例 #33
0
ファイル: test_dirstack.py プロジェクト: BlaXpirit/xonsh
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
コード例 #34
0
ファイル: test_dirstack.py プロジェクト: AndreaCrotti/xonsh
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
コード例 #35
0
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
コード例 #36
0
ファイル: test_dirstack.py プロジェクト: barry-scott/xonsh
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
コード例 #37
0
ファイル: test_dirstack_unc.py プロジェクト: mitnk/xonsh
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"
コード例 #38
0
ファイル: test_dirstack_unc.py プロジェクト: zzp0/xonsh
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'
コード例 #39
0
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'
コード例 #40
0
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()
コード例 #41
0
ファイル: test_dirstack_unc.py プロジェクト: zzp0/xonsh
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()
コード例 #42
0
ファイル: keybindings.py プロジェクト: philopon/.xonsh
 def go_up(event):
     dirstack.cd([os.path.dirname(__xonsh__.env['PWD'])])
     event.current_buffer.validate_and_handle()
コード例 #43
0
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
コード例 #44
0
ファイル: test_dirstack.py プロジェクト: semyon-san/xonsh
def test_simple():
    load_builtins()
    with chdir(PARENT):
        assert_not_equal(os.getcwd(), HERE)
        dirstack.cd(["tests"])
        assert_equal(os.getcwd(), HERE)
コード例 #45
0
ファイル: test_dirstack.py プロジェクト: semyon-san/xonsh
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)
コード例 #46
0
ファイル: test_dirstack.py プロジェクト: carriercomm/xonsh
def test_simple():
    load_builtins()
    with chdir(PARENT):
        assert_not_equal(os.getcwd(), HERE)
        dirstack.cd(["tests"])
        assert_equal(os.getcwd(), HERE)
コード例 #47
0
ファイル: test_dirstack.py プロジェクト: barry-scott/xonsh
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
コード例 #48
0
ファイル: test_dirstack.py プロジェクト: carriercomm/xonsh
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)
コード例 #49
0
ファイル: test_dirstack.py プロジェクト: AndreaCrotti/xonsh
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
コード例 #50
0
def test_cd_dot(xession):
    xession.env = Env(PWD=os.getcwd())

    owd = os.getcwd().casefold()
    dirstack.cd(["."])
    assert owd == os.getcwd().casefold()