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

    # Each should have warned exactly once, and note what to use instead.
    messages = [str(w.message) for w in ctx]

    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 access works but warns and is a deliberate mypy error.
test/deprecation/test_toplevel.py