Example #1
0
def test_path_translations():
    paths = [
        (r";z:\miniconda\Scripts\pip.exe", ":/z/miniconda/Scripts/pip.exe",
         ":/cygdrive/z/miniconda/Scripts/pip.exe"),
        (r";z:\miniconda;z:\Documents (x86)\pip.exe;C:\test",
         ":/z/miniconda:/z/Documents (x86)/pip.exe:/C/test",
         ":/cygdrive/z/miniconda:/cygdrive/z/Documents (x86)/pip.exe:/cygdrive/C/test"
         ),
        # Failures:
        # (r"z:\miniconda\Scripts\pip.exe",
        #  "/z/miniconda/Scripts/pip.exe",
        #  "/cygdrive/z/miniconda/Scripts/pip.exe"),

        # ("z:\\miniconda\\",
        #  "/z/miniconda/",
        #  "/cygdrive/z/miniconda/"),
        ("test dummy text /usr/bin;z:\\documents (x86)\\code\\conda\\tests\\envskhkzts\\test1;z:\\documents\\code\\conda\\tests\\envskhkzts\\test1\\cmd more dummy text",
         "test dummy text /usr/bin:/z/documents (x86)/code/conda/tests/envskhkzts/test1:/z/documents/code/conda/tests/envskhkzts/test1/cmd more dummy text",
         "test dummy text /usr/bin:/cygdrive/z/documents (x86)/code/conda/tests/envskhkzts/test1:/cygdrive/z/documents/code/conda/tests/envskhkzts/test1/cmd more dummy text"
         ),
    ]
    for windows_path, unix_path, cygwin_path in paths:
        assert win_path_to_unix(windows_path) == unix_path
        assert utils.unix_path_to_win(unix_path) == windows_path

        assert utils.win_path_to_cygwin(windows_path) == cygwin_path
        assert utils.cygwin_path_to_win(cygwin_path) == windows_path
Example #2
0
def test_path_translations():
    paths = [
        (r";z:\miniconda\Scripts\pip.exe", ":/z/miniconda/Scripts/pip.exe", ":/cygdrive/z/miniconda/Scripts/pip.exe"),
        (
            r";z:\miniconda;z:\Documents (x86)\pip.exe;C:\test",
            ":/z/miniconda:/z/Documents (x86)/pip.exe:/C/test",
            ":/cygdrive/z/miniconda:/cygdrive/z/Documents (x86)/pip.exe:/cygdrive/C/test",
        ),
        # Failures:
        # (r"z:\miniconda\Scripts\pip.exe",
        #  "/z/miniconda/Scripts/pip.exe",
        #  "/cygdrive/z/miniconda/Scripts/pip.exe"),
        # ("z:\\miniconda\\",
        #  "/z/miniconda/",
        #  "/cygdrive/z/miniconda/"),
        (
            "test dummy text /usr/bin;z:\\documents (x86)\\code\\conda\\tests\\envskhkzts\\test1;z:\\documents\\code\\conda\\tests\\envskhkzts\\test1\\cmd more dummy text",
            "test dummy text /usr/bin:/z/documents (x86)/code/conda/tests/envskhkzts/test1:/z/documents/code/conda/tests/envskhkzts/test1/cmd more dummy text",
            "test dummy text /usr/bin:/cygdrive/z/documents (x86)/code/conda/tests/envskhkzts/test1:/cygdrive/z/documents/code/conda/tests/envskhkzts/test1/cmd more dummy text",
        ),
    ]
    for windows_path, unix_path, cygwin_path in paths:
        assert utils.win_path_to_unix(windows_path) == unix_path
        assert utils.unix_path_to_win(unix_path) == windows_path

        assert utils.win_path_to_cygwin(windows_path) == cygwin_path
        assert utils.cygwin_path_to_win(cygwin_path) == windows_path
Example #3
0
def test_path_translation():
    test_cygwin_path = "test dummy text /usr/bin:/cygdrive/z/documents (x86)/code/conda/tests/envskhkzts/test1:/cygdrive/z/documents/code/conda/tests/envskhkzts/test1/cmd more dummy text"
    test_unix_path = "test dummy text /usr/bin:/z/documents (x86)/code/conda/tests/envskhkzts/test1:/z/documents/code/conda/tests/envskhkzts/test1/cmd more dummy text"
    test_win_path = "test dummy text /usr/bin;z:\\documents (x86)\\code\\conda\\tests\\envskhkzts\\test1;z:\\documents\\code\\conda\\tests\\envskhkzts\\test1\\cmd more dummy text"
    assert_equals(test_win_path, unix_path_to_win(test_unix_path))
    assert_equals(test_unix_path, win_path_to_unix(test_win_path))
    assert_equals(test_cygwin_path, win_path_to_cygwin(test_win_path))
    assert_equals(test_win_path, cygwin_path_to_win(test_cygwin_path))
Example #4
0
def test_path_translation():
    test_cygwin_path = "test dummy text /usr/bin:/cygdrive/z/documents (x86)/code/conda/tests/envskhkzts/test1:/cygdrive/z/documents/code/conda/tests/envskhkzts/test1/cmd more dummy text"
    test_unix_path = "test dummy text /usr/bin:/z/documents (x86)/code/conda/tests/envskhkzts/test1:/z/documents/code/conda/tests/envskhkzts/test1/cmd more dummy text"
    test_win_path = "test dummy text /usr/bin;z:\\documents (x86)\\code\\conda\\tests\\envskhkzts\\test1;z:\\documents\\code\\conda\\tests\\envskhkzts\\test1\\cmd more dummy text"
    assert_equals(test_win_path, unix_path_to_win(test_unix_path))
    assert_equals(test_unix_path, win_path_to_unix(test_win_path))
    assert_equals(test_cygwin_path, win_path_to_cygwin(test_win_path))
    assert_equals(test_win_path, cygwin_path_to_win(test_cygwin_path))
Example #5
0
def convert_unix_path_to_win(path):
    if external.find_executable('cygpath'):
        cmd = "cygpath -w {0}".format(path)
        if PY3:
            path = subprocess.getoutput(cmd)
        else:
            path = subprocess.check_output(cmd.split()).rstrip().rstrip("\\")

    else:
        path = unix_path_to_win(path)
    return path
Example #6
0
def convert_unix_path_to_win(path):
    if external.find_executable("cygpath"):
        cmd = "cygpath -w {0}".format(path)
        if PY3:
            path = subprocess.getoutput(cmd)
        else:
            path = subprocess.check_output(cmd.split()).rstrip().rstrip("\\")

    else:
        path = unix_path_to_win(path)
    return path
Example #7
0
def test_path_translations():
    paths = [
        (r";z:\miniconda\Scripts\pip.exe",
         ":/z/miniconda/Scripts/pip.exe",
         ":/cygdrive/z/miniconda/Scripts/pip.exe"),
        (r";z:\miniconda;z:\Documents (x86)\pip.exe;C:\test",
         ":/z/miniconda:/z/Documents (x86)/pip.exe:/C/test",
         ":/cygdrive/z/miniconda:/cygdrive/z/Documents (x86)/pip.exe:/cygdrive/C/test"),
        # Failures:
        # (r"z:\miniconda\Scripts\pip.exe",
        #  "/z/miniconda/Scripts/pip.exe",
        #  "/cygdrive/z/miniconda/Scripts/pip.exe"),

        # ("z:\\miniconda\\",
        #  "/z/miniconda/",
        #  "/cygdrive/z/miniconda/"),
        ("test dummy text /usr/bin;z:\\documents (x86)\\code\\conda\\tests\\envskhkzts\\test1;z:\\documents\\code\\conda\\tests\\envskhkzts\\test1\\cmd more dummy text",
        "test dummy text /usr/bin:/z/documents (x86)/code/conda/tests/envskhkzts/test1:/z/documents/code/conda/tests/envskhkzts/test1/cmd more dummy text",
        "test dummy text /usr/bin:/cygdrive/z/documents (x86)/code/conda/tests/envskhkzts/test1:/cygdrive/z/documents/code/conda/tests/envskhkzts/test1/cmd more dummy text"),
    ]
    for windows_path, unix_path, cygwin_path in paths:
        win2unix = utils.win_path_to_unix(windows_path)
        unix2win = utils.unix_path_to_win(unix_path)

        win2cygwin = utils.win_path_to_cygwin(windows_path)
        cygwin2win = utils.cygwin_path_to_win(cygwin_path)

        print("win2unix == unix_path :: {} == {} :: {}".format(
            win2unix,
            unix_path,
            win2unix == unix_path))
        print("unix2win == windows_path :: {} == {} :: {}".format(
            unix2win,
            windows_path,
            unix2win == windows_path))

        print("win2cygwin == cygwin_path :: {} == {} :: {}".format(
            win2cygwin,
            cygwin_path,
            win2cygwin == cygwin_path))
        print("cygwin2win == windows_path :: {} == {} :: {}".format(
            cygwin2win,
            windows_path,
            cygwin2win == windows_path))

        assert win2unix == unix_path
        assert unix2win == windows_path

        assert win2cygwin == cygwin_path
        assert cygwin2win == windows_path
Example #8
0
def test_text_translations():
    test_win_text = "prepending z:\\msarahan\\code\\conda\\tests\\envsk5_b4i\\test 1 and z:\\msarahan\\code\\conda\\tests\\envsk5_b4i\\test 1\\scripts to path"
    test_unix_text = "prepending /z/msarahan/code/conda/tests/envsk5_b4i/test 1 and /z/msarahan/code/conda/tests/envsk5_b4i/test 1/scripts to path"
    assert_equals(test_win_text, utils.unix_path_to_win(test_unix_text))
    assert_equals(test_unix_text, utils.win_path_to_unix(test_win_text))
Example #9
0
def make_win_ok(path):
    if on_win:
        return unix_path_to_win(path)
    else:
        return path
Example #10
0
def test_text_translations():
    test_win_text = "prepending z:\\msarahan\\code\\conda\\tests\\envsk5_b4i\\test 1 and z:\\msarahan\\code\\conda\\tests\\envsk5_b4i\\test 1\\scripts to path"
    test_unix_text = "prepending /z/msarahan/code/conda/tests/envsk5_b4i/test 1 and /z/msarahan/code/conda/tests/envsk5_b4i/test 1/scripts to path"
    assert_equals(test_win_text, utils.unix_path_to_win(test_unix_text))
    assert_equals(test_unix_text, win_path_to_unix(test_win_text))
Example #11
0
def test_text_translations():
    test_win_text = "z:\\msarahan\\code\\conda\\tests\\envsk5_b4i\\test 1"
    test_unix_text = "/z/msarahan/code/conda/tests/envsk5_b4i/test 1"
    assert_equals(test_win_text, utils.unix_path_to_win(test_unix_text))
    assert_equals(test_unix_text, win_path_to_unix(test_win_text))
Example #12
0
def make_win_ok(path):
    if on_win:
        return unix_path_to_win(path)
    else:
        return path
Example #13
0
def test_text_translations():
    test_win_text = "z:\\msarahan\\code\\conda\\tests\\envsk5_b4i\\test 1"
    test_unix_text = "/z/msarahan/code/conda/tests/envsk5_b4i/test 1"
    assert_equals(test_win_text, utils.unix_path_to_win(test_unix_text))
    assert_equals(test_unix_text, win_path_to_unix(test_win_text))