import re


def test_invalid_patterns(list, pattern):
    """
    Function to facilitate the tests in MyRegExTest class
    :param list: list with strings of invalid cases
    :param pattern: a regular expression
    :return: list with the result of all matches which should be a list of None
    """
    newList = []
    for item in list:
        matched = re.match(pattern, item)
        if matched is None:
            newList.append(None)
        else:
            raise ValueError(item + ' matched to ' + pattern + ' while it should not have matched')

    return newList