Example #1
0
def step_impl(context, first, second):
    full_path_first = prepend_installroot(context, first)
    full_path_second = prepend_installroot(context, second)
    f1 = find_file_by_glob(full_path_first)
    f2 = find_file_by_glob(full_path_second)
    found1 = read_file_contents(f1).strip()
    found2 = read_file_contents(f2).strip()
    if found1 == found2:
        return
    print_lines_diff(found1.split('\n'), found2.split('\n'))
    raise AssertionError("File '{}' contents differ from {}.".format(first, second))
Example #2
0
def file_contents_is(context, filepath):
    expected = context.text.strip()
    full_path = prepend_installroot(context, filepath)
    f = find_file_by_glob(full_path)
    found = read_file_contents(f).strip()
    if expected == found:
        return
    print_lines_diff(expected.split('\n'), found.split('\n'))
    raise AssertionError("File '{}' contents is different then expected.".format(filepath))
Example #3
0
def then_stdout_matches_line_by_line(context, filepath):
    """
    Checks that each line of given file matches respective line in regular expressions.
    """
    expected = context.text.split('\n')
    full_path = prepend_installroot(context, filepath)
    f = find_file_by_glob(full_path)
    found = read_file_contents(f).split('\n')

    lines_match_to_regexps_line_by_line(found, expected)
Example #4
0
def file_does_not_contain(context, filepath):
    regexp_lines = context.text.split('\n')
    full_path = prepend_installroot(context, filepath)
    ensure_directory_exists(os.path.dirname(full_path))
    read_str = read_file_contents(full_path)
    for line in regexp_lines:
        if re.search(line, read_str):
            print("line: " + line + " found")
            raise AssertionError("File %s contains: \n%s" % (filepath, read_str))
    return
Example #5
0
def create_compressed_file_with(context, compression, filepath):
    file_path = prepend_installroot(context, filepath)
    ensure_file_exists(file_path)
    create_compressed_file_with_contents(file_path, compression,
                                         read_file_contents(file_path))