def _is_fk_msg(dialect, msg, key_cname, ref_cname):
    """
        easier unit testing this way
    """
    if dialect == 'sqlite':
        if ('violates foreign key constraint' in msg and '__%s__fk' %
            key_cname in msg):
            return True
    elif dialect == 'postgresql':
        msg = msg.replace('(psycopg2.IntegrityError) ', '', 1)
        if 'violates foreign key constraint' in msg:
            if msg.startswith('insert or update'
                ) and 'Key (%s)=' % key_cname in msg:
                return True
            if msg.startswith('update or delete'
                ) and 'Key (%s)=' % ref_cname in msg:
                return True
    elif dialect == 'mssql':
        is_fk_message = 'conflicted with the FOREIGN KEY constraint' in msg
        is_ref_message = 'conflicted with the REFERENCE constraint' in msg
        if is_fk_message and "column \\'%s\\'" % ref_cname in msg:
            return True
        if is_ref_message and "column \\'%s\\'" % key_cname in msg:
            return True
    else:
        raise ValueError('is_fk_exc() does not yet support dialect: %s' %
            dialect)
    return False
