def METHOD_NAME(result_image_name):
    """
    Extracts the name of the test which a result image refers to
    """
    name_match = _RESULT_NAME_PATTERN.match(str(result_image_name))
    if name_match:
        test_key = name_match.group(1)
    else:
        emsg = f"Incorrectly named image in result dir: {result_image_name}"
        raise ValueError(emsg)
    return test_key