import random
import string


def generate_test_cases(pattern, length, k):
    """
    Generates <k> test cases with text of length <length> containing <pattern>

    Args:
        pattern (str): A pattern within the text.
        length (int): The length of the pattern
        k (int): The number of test cases

    Returns:
        A list of test cases, i.e. strings that contain <pattern>
    """
    result = []
    for _ in range(k):
        text = pattern
        while len(text) < length:
            direction = random.choice((0, 1))

            # 0 --> Left
            if direction == 0:
                text = random.choice(string.ascii_lowercase) + text

            # 1 --> Right
            else:
                text = text + random.choice(string.ascii_lowercase)

        result.append(text)

    return result