def compare_lines(expected_path, to_test_path, num_lines, reverse=False):
    """Compares the first n lines of two files.

    Args:
        expected_path: Path to the file with the expected content, as a string.
        to_test_path: Path to the file to compare with the expected file,
            as a string.
        num_lines: Number of lines to compare, as an int.
        reverse: Whether to compare the last n lines, as a boolean.

    Returns:
        True, if the two files have the same content. False, otherwise.
    """
    with open(expected_path, 'rb') as expected:
        with open(to_test_path, 'rb') as to_test:
            expected_lines = None
            lines_to_test = None
            if reverse:
                expected_lines = expected.readlines()[-num_lines:]
                lines_to_test = to_test.readlines()[-num_lines:]
            else:
                expected_lines = expected.readlines()[:num_lines]
                lines_to_test = to_test.readlines()[:num_lines]
            if len(lines_to_test) != len(expected_lines):
                print(f'Expected to test {len(lines_to_test)} lines but '
                      f'got {len(expected_lines)} lines')
                return False
            for i in range(min(len(lines_to_test), num_lines)):
                expected_line = expected_lines[i]
                line_to_test = lines_to_test[i]
                if expected_line != line_to_test:
                    print('WANT:', expected_line)
                    print('GOT:', line_to_test)
                    return False
            return True