def get_user() -> str | None:
    """Return the current user name, or None if getuser() does not work
    in the current environment (see #1010)."""
    try:
        # In some exotic environments, getpass may not be importable.
        import getpass

        return getpass.getuser()
    except (ImportError, OSError, KeyError):
        return None
Return the current user name, or None if getuser() does not work
    in the current environment (see #1010).
src/_pytest/tmpdir.py