Beispiel #1
0
def utils_unit_test():
    """
    Unit testing on various utility code.
    """

    s = utils.c_escape("Hello World!")
    assert s == "Hello World!"

    s = utils.c_escape("Test \" \\ One")

    assert s == "Test \\\" \\\\ One"

    s = utils.pad_to("0123456789", 11)
    assert s == "0123456789 "

    s = utils.pad_to("0123456789", 8)
    assert s == "0123456789"

    s = utils.pad_to("0", 10, "z")
    assert s == "0zzzzzzzzz"

    s = utils.split_path_left("a/b/c")

    assert s == ("a", "b/c")

    s = utils.split_path_left("/a/b/c")
    assert s == ("", "a/b/c")

    s = utils.replace_root_name("/a", "/b", "/a/c")
    assert s == "/b/c"

    s = utils.replace_root_name("/a", "/b", "/d/e")
    assert s == "/d/e"
Beispiel #2
0
def utils_unit_test():
    """
    Unit testing on various utility code.
    """

    s = utils.c_escape("Hello World!")
    assert s == "Hello World!"

    s = utils.c_escape("Test \" \\ One")

    assert s == "Test \\\" \\\\ One"

    s = utils.pad_to("0123456789", 11)
    assert s == "0123456789 "

    s = utils.pad_to("0123456789", 8)
    assert s == "0123456789"

    s = utils.pad_to("0", 10, "z")
    assert s == "0zzzzzzzzz"

    s = utils.split_path_left("a/b/c")

    assert s == ("a", "b/c")

    s = utils.split_path_left("/a/b/c")
    assert s == ("", "a/b/c")

    s = utils.replace_root_name("/a", "/b", "/a/c")
    assert s == "/b/c"

    s = utils.replace_root_name("/a", "/b", "/d/e")
    assert s == "/d/e"
Beispiel #3
0
def list_registered(indent=''):
    """
    Return a list of registered version control systems.
    """

    str_list = []
    for (k, v) in vcs_dict.items():
        if indent:
            str_list.append(indent)
        str_list.append(utils.pad_to(k, 20))
        desc = v.long_name
        lines = desc.split("\n")
        str_list.append(lines[0])
        str_list.append("\n")
        for i in lines[1:]:
            if indent:
                str_list.append(indent)
            str_list.append(utils.pad_to("", 20))
            str_list.append(i)
            str_list.append("\n")

    return "".join(str_list)
Beispiel #4
0
def list_registered(indent=''):
    """
    Return a list of registered version control systems.
    """

    str_list = []
    for (k,v) in vcs_dict.items():
        if indent:
            str_list.append(indent)
        str_list.append(utils.pad_to(k, 20))
        desc = v.long_name
        lines = desc.split("\n")
        str_list.append(lines[0])
        str_list.append("\n")
        for i in lines[1:]:
            if indent:
                str_list.append(indent)
            str_list.append(utils.pad_to("", 20))
            str_list.append(i)
            str_list.append("\n")

    return "".join(str_list)