def _make_message_set(messages):
    """
    Unfortunately `django.core.checks.CheckMessage` doesn't implement
    `__hash__()`, so sets containing them cannot be compared directly.
    As a workaround this makes a set containing tuples of the level
    and message, which are the only two attributes the tests care about.

    Example:
    >>> from django.core.checks import Critical
    >>> c1 = Critical("foobar")
    >>> c2 = Critical("foobar")
    >>> c1 == c2
    True
    >>> {c1} == {c2}
    False
    >>> _make_message_set({c1}) == _make_message_set({c2})
    True

    """
    return {(m.level, m.msg) for m in messages}