예제 #1
0
def test_cdpath_expansion(xonsh_builtins):
    xonsh_builtins.__xonsh_env__ = Env(HERE=HERE, CDPATH=("~", "$HERE"))
    test_dirs = (os.path.join(HERE, "xonsh-test-cdpath-here"),
                 os.path.expanduser("~/xonsh-test-cdpath-home"))
    try:
        for _ in test_dirs:
            if not os.path.exists(_):
                os.mkdir(_)
            assert os.path.exists(dirstack._try_cdpath(
                _)), "dirstack._try_cdpath: could not resolve {0}".format(_)
    except Exception as e:
        tuple(os.rmdir(_) for _ in test_dirs if os.path.exists(_))
        raise e
예제 #2
0
def test_cdpath_expansion():
    with xonsh_env(Env(HERE=HERE, CDPATH=("~", "$HERE"))):
        test_dirs = (
            os.path.join(HERE, "xonsh-test-cdpath-here"),
            os.path.expanduser("~/xonsh-test-cdpath-home")
        )
        try:
            for _ in test_dirs:
                if not os.path.exists(_):
                    os.mkdir(_)
                assert os.path.exists(dirstack._try_cdpath(_)), "dirstack._try_cdpath: could not resolve {0}".format(_)
        except Exception as e:
            tuple(os.rmdir(_) for _ in test_dirs if os.path.exists(_))
            raise e
예제 #3
0
def test_cdpath_expansion(xonsh_builtins):
    xonsh_builtins.__xonsh_env__ = Env(HERE=HERE, CDPATH=("~", "$HERE"))
    test_dirs = (os.path.join(HERE, "xonsh-test-cdpath-here"),
                 os.path.expanduser("~/xonsh-test-cdpath-home"))
    try:
        for d in test_dirs:
            if not os.path.exists(d):
                os.mkdir(d)
            assert os.path.exists(dirstack._try_cdpath(
                d)), "dirstack._try_cdpath: could not resolve {0}".format(d)
    finally:
        for d in test_dirs:
            if os.path.exists(d):
                os.rmdir(d)
예제 #4
0
def test_cdpath_expansion(xonsh_builtins):
    xonsh_builtins.__xonsh_env__ = Env(HERE=HERE, CDPATH=("~", "$HERE"))
    test_dirs = (
        os.path.join(HERE, "xonsh-test-cdpath-here"),
        os.path.expanduser("~/xonsh-test-cdpath-home")
    )
    try:
        for d in test_dirs:
            if not os.path.exists(d):
                os.mkdir(d)
            assert os.path.exists(dirstack._try_cdpath(d)), "dirstack._try_cdpath: could not resolve {0}".format(d)
    finally:
        for d in test_dirs:
            if os.path.exists(d):
                os.rmdir(d)
예제 #5
0
def test_cdpath_expansion(xession):
    xession.env.update(dict(HERE=HERE, CDPATH=("~", "$HERE")))
    test_dirs = (
        os.path.join(HERE, "xonsh-test-cdpath-here"),
        os.path.expanduser("~/xonsh-test-cdpath-home"),
    )
    try:
        for d in test_dirs:
            if not os.path.exists(d):
                os.mkdir(d)
            assert os.path.exists(dirstack._try_cdpath(
                d)), f"dirstack._try_cdpath: could not resolve {d}"
    finally:
        for d in test_dirs:
            if os.path.exists(d):
                os.rmdir(d)