def test():
    main(FILE_NAME)

    with open(FILE_NAME, 'r') as f:
        contents = f.readlines()

    for line in contents:
        # only split lines that look like a key/value pair.
        if ':' in line:
            var, value = line.split(':', 1)
            value = value.strip()
        elif '/' in line:
            # For the comment containing a variable, clean up the list
            # contents before assigning the parts we want to test.
            parts = line.split()
            parts.remove('#')
            parts.remove('/')
            var, value = parts
        else:
            var = value = line


        # Once run through the 'main' function, the keys and values should
        # match
        if not value == var:
            import pdb; pdb.set_trace()  # NOQA
            print("Var and value don't match.")
            print("Var: {}, Value: {}".format(var, value))
            sys.exit()

        invalid_variable = var not in VAR_MAPPINGS.values()
        # Comments aren't in our test mapping, so make sure we ignore them
        is_comment = line.startswith('#')

        if invalid_variable and not is_comment:
            err = "Variable {} doesn't appear to be a valid new name."
            sys.exit(err.format(var))


    print("Tests passed")
Пример #2
0
def test():
    main(FILE_NAME)

    with open(FILE_NAME, 'r') as f:
        contents = f.readlines()

    for line in contents:
        # only split lines that look like a key/value pair.
        if ':' in line:
            var, value = line.split(':', 1)
            value = value.strip()
        elif '/' in line:
            # For the comment containing a variable, clean up the list
            # contents before assigning the parts we want to test.
            parts = line.split()
            parts.remove('#')
            parts.remove('/')
            var, value = parts
        else:
            var = value = line

        # Once run through the 'main' function, the keys and values should
        # match
        if not value == var:
            import pdb
            pdb.set_trace()  # NOQA
            print("Var and value don't match.")
            print("Var: {}, Value: {}".format(var, value))
            sys.exit()

        invalid_variable = var not in VAR_MAPPINGS.values()
        # Comments aren't in our test mapping, so make sure we ignore them
        is_comment = line.startswith('#')

        if invalid_variable and not is_comment:
            err = "Variable {} doesn't appear to be a valid new name."
            sys.exit(err.format(var))

    print("Tests passed")