def test_private_module_alias_import() -> None:
    """Non-util private alias import works but warns and is a deliberate mypy error."""
    with pytest.deprecated_call() as ctx:
        from git import head  # type: ignore[attr-defined]
        from git import log  # type: ignore[attr-defined]
        from git import reference  # type: ignore[attr-defined]
        from git import symbolic  # type: ignore[attr-defined]
        from git import tag  # type: ignore[attr-defined]
        from git import base  # type: ignore[attr-defined]
        from git import fun  # type: ignore[attr-defined]
        from git import typ  # type: ignore[attr-defined]

    assert (
        head,
        log,
        reference,
        symbolic,
        tag,
        base,
        fun,
        typ,
    ) == _PRIVATE_MODULE_ALIAS_TARGETS

    # Each import may warn multiple times. In CPython there will be currently always be
    # exactly two warnings per import, possibly due to the equivalent of calling hasattr
    # to do a pre-check prior to retrieving the attribute for actual use. However, for
    # each import, all messages should be the same and should note what to use instead.
    messages_with_duplicates = [str(w.message) for w in ctx]
    messages = [message for message, _ in itertools.groupby(messages_with_duplicates)]

    assert len(messages) == len(_PRIVATE_MODULE_ALIAS_TARGETS)

    for fullname, message in zip(_PRIVATE_MODULE_ALIAS_TARGET_NAMES, messages):
        assert message.endswith(f"Use {fullname} instead.")
Non-util private alias import works but warns and is a deliberate mypy error.
test/deprecation/test_toplevel.py